-
-
Save imotov/eb0f09a58668af4b726f to your computer and use it in GitHub Desktop.
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
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