Skip to content

Instantly share code, notes, and snippets.

@jprante
Created November 1, 2014 23:14
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 jprante/ed6a78a4cee6fdf33b7f to your computer and use it in GitHub Desktop.
Save jprante/ed6a78a4cee6fdf33b7f to your computer and use it in GitHub Desktop.
Must/should filter
curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test/test/1' -d '
{
"location" : "germany",
"valueType" : "integer"
}
'
curl -XGET 'localhost:9200/test/_refresh'
curl -XGET 'localhost:9200/test/_search?pretty' -d '
{
"query": {
"bool": {
"must": {
"terms": { "location": ["germany" ]}
},
"should": {
"terms": { "valueType": ["integer"] }
}
}
}
}
'
curl -XGET 'localhost:9200/test/_search?pretty' -d '
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": {
"terms": { "location": ["germany"] }
},
"should": {
"terms": { "valueType": ["integer"] }
}
}
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment