Skip to content

Instantly share code, notes, and snippets.

@imotov
Created October 4, 2013 23:08
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 imotov/eb0f09a58668af4b726f to your computer and use it in GitHub Desktop.
Save imotov/eb0f09a58668af4b726f to your computer and use it in GitHub Desktop.
curl -XPUT localhost:9200/products-test -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"product": {
"properties": {
"id": { "type": "integer", "store": true },
"name": { "type": "string", "store": "yes" },
"kind": { "type": "string", "store": "no" },
"tags": {
"type": "nested",
"properties": {
"slug": { "type": "string" },
"label": { "type": "string" }
}
}
}
}
}
}'
curl -XPOST "localhost:9200/products-test/product?refresh" -d '{
"id": "112",
"tags": [
{"slug": "black"}
]
}'
curl -XPOST "localhost:9200/products-test/product?refresh" -d '{
"id": "113",
"tags": [
{"slug": "red"}
]
}'
echo
curl "localhost:9200/products-test/product/_search?fields=id&pretty" -d '{
"query": {
"nested": {
"path": "tags",
"filter": {
"bool": {
"must": {
"terms": {
"tags.slug": [ "discount", "black"]
}
}
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment