Created
November 9, 2012 20:19
-
-
Save radu-gheorghe/4047982 to your computer and use it in GitHub Desktop.
child object ID search
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
#!/bin/bash | |
#delete the test index | |
curl -XDELETE localhost:9200/testing/ | |
echo | |
#put the document | |
curl -XPOST localhost:9200/testing/testing/ -d '{ | |
"document": { | |
"title": "foo", | |
"id": 1, | |
"tags": [ | |
{ | |
"id": 3, | |
"value": "bar" | |
}, | |
{ | |
"id": 4, | |
"value": "baz" | |
} | |
] | |
} | |
}' | |
echo | |
#refresh | |
curl -XPOST localhost:9200/testing/_refresh | |
echo | |
#sleeping like a boss, to avoid any races. Ironic, ha? | |
sleep 1 | |
#search for ID | |
curl -XPOST localhost:9200/testing/testing/_search?pretty=true -d '{ | |
"query": { | |
"term": { | |
"document.tags.id": 4 | |
} | |
} | |
}' | |
echo | |
#search for value | |
curl -XPOST localhost:9200/testing/testing/_search?pretty=true -d '{ | |
"query": { | |
"term": { | |
"document.tags.value": "baz" | |
} | |
} | |
}' | |
echo | |
#and here's the auto-detected mapping | |
curl -XGET localhost:9200/testing/testing/_mapping/?pretty=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment