airza hit the nail on the head with his answer in terms of the filter you're looking for, in CURL format. I suspect the issues you're seeing are largely due to using an abstraction module like elasticutils
- it would be good to get familiar with the underlying ES querying protocol first. It will make understanding elasticutils
easier. As in my comment above, I recommend installing 'Sense', a plugin for Google Chrome that let's you easily query your ES cluster: https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpbo?hl=en.
Elasticsearch query filters are extremely flexible - and 'nestable'. You can quite easily nest an or
filter inside of a bool
must
filter. Example:
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"or": [
{"exists": {"field": "sessions"}},
{"range": {"id": {"gte": 56000}}}
]
},
{
"term": {"age_min": "13"}
}
],
"should": [
{
"term": {"area": "1"}
}
]
}
}
}
}
}
In this example, results must match one of the two must
or
filters and the age_min
term
filter, and items matching the area
term
filter in the should
clause will rank higher than non-matching items.