bool 查询 - 必须和应该在同一级别,这是什么意思?

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

bool query with must and should on same level 是什么意思?

我看到下面的查询:

{
  "query": {
    "bool": {
        
     "must": 
        [{
          "match": {
            "content": {
              "reporter": "Ricky"             
            }
          }
        }], 
        
      "should": 
      [{
          "match": {
            "header": {
              "query": "nature"
            }
          }
        }]
      
    }
  }
}
  1. 那么这个 bool 查询是什么意思?
  2. 这里 should 是否对最终分数有贡献(如果 must 查询不占任何位置)?

must + should 只是提高搜索相关性,而不仅仅是 and + or

  1. 上述查询的意思是:找到所有 content 字段包含“ricky”的文档,并为那些在 header 中也包含“nature”的文档提供一点提升场.

  2. 必须满足 must 中的查询 ,即如果没有文档在其 content 字段中包含“ricky”,则在结果集中不会有任何匹配项。