Skip to content

Instantly share code, notes, and snippets.

@un1t
Created January 11, 2017 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save un1t/47506a95a26227a01d2c5d6e063790f3 to your computer and use it in GitHub Desktop.
Save un1t/47506a95a26227a01d2c5d6e063790f3 to your computer and use it in GitHub Desktop.
curl -XPUT 'http://localhost:9200/_bulk?pretty' -d '
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "1" } }
{ "title" : "The NoSQL database glut", "journal" : "2", "author": [{"title": "August S"}, {"title": "Weiss P L"}] }
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "2" } }
{ "title" : "Graph Databases Seen Connecting the Dots", "journal" : "1", "author": [{"title": "Weiss S"}] }
'
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '{"query": {"match": {"author.title": {"query": "weiss s", "operator": "and"}}}}'
curl -XGET 'http://localhost:9200/test/_mapping?pretty'
{
"test" : {
"mappings" : {
"publication" : {
"properties" : {
"author" : {
"properties" : {
"title" : {
"type" : "string"
}
}
},
"journal" : {
"type" : "string"
},
"title" : {
"type" : "string"
}
}
}
}
}
}
curl -XDELETE http://localhost:9200/test
curl -XPUT 'http://localhost:9200/test/' -d '
{
"mappings" : {
"publication" : {
"properties" : {
"author" : {
"type": "nested",
"properties" : {
"title" : {
"type" : "string"
}
}
},
"journal" : {
"type" : "string"
},
"title" : {
"type" : "string"
}
}
}
}
}
'
curl -XGET 'http://localhost:9200/test/_mapping?pretty'
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '
{
"query": {
"nested": {
"path": "author",
"query": {
"match": {
"author.title": {
"query": "weiss s", "operator": "and"
}
}
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment