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

  1. doesn't seem logic structure?
  2. 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

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -