Created
February 22, 2013 02:41
-
-
Save bbansal/5010329 to your computer and use it in GitHub Desktop.
Elastic search nested query issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a new index | |
curl -XPUT http://localhost:9200/newindex | |
# Create a nested mapping | |
curl -XPUT http://localhost:9200/newindex/foo/_mapping -d '{"foo" : {"properties": { "nested_field" : { "type": "nested" }} }}' | |
# Add a document | |
curl -XPUT http://localhost:9200/newindex/foo/5812395 -d '{ "nested_field" : [ { "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 } ], "id":5812395 }' | |
# Refresh the index | |
curl -XPOST http://localhost:9200/newindex/_refresh | |
# Query the nested for one pair of nested values. | |
curl -XGET http://localhost:9200/newindex/foo/_search?pretty=true -d '{ "query" : {"nested" : { "path" : "nested_field", "query": { "query_string": { "query": "name:blue AND count:4" }}}}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment