Elasticsearch bool query with filter -


i trying write elasticsearch bool query of 2 parts. want 2 conditions "must" , 2 "should". problem want score "should". tried "filter" without success.

to more specific, query made here:

{   "query": {     "bool": {       "must": [         {           "match": {             "attr1": "on"           }         },         {           "match": {             "category": "7eb84c804a8c824fd608e05f78d42f10"           }         }       ],       "should": [         {           "term": {             "attr2": "on"           }         },         {           "term": {             "attr3": "on"           }         }       ],       "minimum_should_match": "10%"     }   } } 

update here query failed , want find error!:

  {   "query": {     "bool": {       "filter": [         {           "term": {             "attr1": "on"           }         },         {           "term": {             "category": "7eb84c804a8c824fd608e05f78d42f10"           }         }       ],       "should": [         {           "term": {             "attr2": "on"           }         },         {           "term": {             "attr3": "on"           }         }       ],       "minimum_should_match": "10%"     }   } } 

how can re-write query in order: 1) rows attr1 , category exact 2) query these results should

any idea please?

seems not on elasticsearch 2.x.

for elasticsearch 1.x use filteredquery: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html

{   "filtered": {     "query": {       "bool": {         "should": [           {             "term": {               "attr2": "on"             }           },           {             "term": {               "attr3": "on"             }           }         ]       }     },     "filter": {       "bool": {         "must": [           {             "match": {               "attr1": "on"             }           },           {             "match": {               "category": "7eb84c804a8c824fd608e05f78d42f10"             }           }         ]       }     }   } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -