Skip to content

Instantly share code, notes, and snippets.

@djpate
Last active August 29, 2015 14:05
Show Gist options
  • Save djpate/517bc9ca8b9c19f0b7ac to your computer and use it in GitHub Desktop.
Save djpate/517bc9ca8b9c19f0b7ac to your computer and use it in GitHub Desktop.
curl -X DELETE "http://localhost:9200/wildcards/"
curl -X POST "http://localhost:9200/wildcards/" -d '{
"mappings": {
"post": {
properties: {
"tags": {
"type": "nested",
"properties": {
"name": {"type": "string"},
"identifier": {"type": "string", "analyzer": "keyword"}
}
}
}
}
}
}'
curl -XPUT 'http://localhost:9200/wildcards/post/1' -d '{
"title": "post1",
"tags": [{"name": "tag1","identifier": "Se"},{"name": "tag2","identifier": "Se*"}]
}'
curl -XPUT 'http://localhost:9200/wildcards/post/2' -d '{
"title": "post2",
"tags": [{"name": "tag1","identifier": "Se*"},{"name": "tag2","identifier": "Se"}]
}'
curl -XGET 'http://localhost:9200/wildcards/post/_search' -d '{
"query": {
"nested": {
"path": "tags",
"query": {
"bool": {
"must": [
{
"match": {
"tags.name": "tag1"
}
},
{
"match": {
"tags.identifier": "Se"
}
}
]
}
}
}
}
}'
curl -XGET 'http://localhost:9200/wildcards/post/_search' -d '{
"query": {
"nested": {
"path": "tags",
"query": {
"bool": {
"must": [
{
"match": {
"tags.name": "tag1"
}
},
{
"match": {
"tags.identifier": "Se*"
}
}
]
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment