Skip to content

Instantly share code, notes, and snippets.

@radu-gheorghe
Created November 9, 2012 20:19
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 radu-gheorghe/4047982 to your computer and use it in GitHub Desktop.
Save radu-gheorghe/4047982 to your computer and use it in GitHub Desktop.
child object ID search
#!/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