Elasticsearch Term and Range in Bool Filter -
i'm trying filter products data product type , price range. don't want score results can 0 or 1, need result-set.
why can't following? seems logical!
elasticsearch version: 5.5
get my_store/products/_search { "query": { "constant_score": { "filter": { "term": { "producttype": "cooker" }, "range": { "price": { "gte": 10, "lte": 20 } } } } } } when execute this, get:
"[term] malformed query, expected [end_object] found [field_name]" which presumably means i'm doing syntactically wrong
- doesn't seem logic structure?
- fine, if it's wrong, i've got adapt... what's correct syntax?
this should solve problem. i'm assuming meant logically , filters. if meant or them, replace "must" "should". reference: https://www.elastic.co/guide/en/elasticsearch/guide/current/combining-filters.html
{ "query": { "constant_score": { "filter": { "bool": { "must": [ { "term": { "producttype": "cooker" } }, { "range": { "price": { "gte": 10, "lte": 20 } } } ] } } } } }
Comments
Post a Comment