Skip to content

Instantly share code, notes, and snippets.

@dhonig
Created April 2, 2014 09:18
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 dhonig/9930712 to your computer and use it in GitHub Desktop.
Save dhonig/9930712 to your computer and use it in GitHub Desktop.
EXAMPLE Filtering within a term query
POST /development_en/product/_search
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"match_all": {}
}
]
}
},
"filter": {
"and": {
"filters": [
{
"terms": {
"taxons.name": [
"mens","hoodies"
],
"execution": "or"
}
}
,{"or": {
"filters": [
{"range": {
"price": {
"from": 0,
"to": 100
}
}}
]
}}
]
}
}
}
},
"sort": [
{
"name": {
"order": "asc"
}
}
],
"from": 0,
"size": 12,
"facets": {
"taxons.name": {
"terms": {
"field": "taxons.name_plain"
}
},
"size": {
"terms": {
"field": "size"
}
},
"price": {
"range": {
"price": [
{
"from": "0",
"to": "50"
},
{
"from": "50",
"to": "100"
},
{
"from": "100",
"to": "150"
},
{
"from": "200",
"to": "500"
},
{
"from": "0",
"to": "1000"
}
]
}
},
"colour": {
"terms": {
"field": "colour"
}
},
"gender": {
"terms": {
"field": "gender"
}
},
"price_histogram": {
"histogram": {
"field": "price",
"interval": 50
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment