Home > other >  bool query - must and should on same level, what does it means?
bool query - must and should on same level, what does it means?

Time:03-15

What does bool query with must and should on same level means ?

I saw the query bellow:

{
  "query": {
    "bool": {
        
     "must": 
        [{
          "match": {
            "content": {
              "reporter": "Ricky"             
            }
          }
        }], 
        
      "should": 
      [{
          "match": {
            "header": {
              "query": "nature"
            }
          }
        }]
      
    }
  }
}
  1. So what does this bool query mean ?
  2. Does should contributes here to the final score (if must query dosn't take any place) ?

CodePudding user response:

must should is only about search relevance improvement and not just and or

  1. the above query means: find me all document whose content field contains "ricky" and give a little boost to those documents also having "nature" in their header field.

  2. The query in must MUST be met, i.e. if no document contain "ricky" in their content field, there won't be any match in the result set.

  • Related