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"
}
}
}]
}
}
}
- 根据Improving search relevance with boolean queries
must
表示and
,should
表示or
- 在上面的查询中
must
和should
(“and”和“or”)在同一层。
- 那么这个 bool 查询是什么意思?
- 这里
should
是否对最终分数有贡献(如果 must
查询不占任何位置)?
must + should 只是提高搜索相关性,而不仅仅是 and + or
上述查询的意思是:找到所有 content
字段包含“ricky”的文档,并为那些在 header
中也包含“nature”的文档提供一点提升场.
必须满足 must
中的查询 ,即如果没有文档在其 content
字段中包含“ricky”,则在结果集中不会有任何匹配项。
bool query with must
and should
on same level 是什么意思?
我看到下面的查询:
{
"query": {
"bool": {
"must":
[{
"match": {
"content": {
"reporter": "Ricky"
}
}
}],
"should":
[{
"match": {
"header": {
"query": "nature"
}
}
}]
}
}
}
- 根据Improving search relevance with boolean queries
must
表示and
,should
表示or
- 在上面的查询中
must
和should
(“and”和“or”)在同一层。
- 那么这个 bool 查询是什么意思?
- 这里
should
是否对最终分数有贡献(如果must
查询不占任何位置)?
must + should 只是提高搜索相关性,而不仅仅是 and + or
上述查询的意思是:找到所有
content
字段包含“ricky”的文档,并为那些在header
中也包含“nature”的文档提供一点提升场.必须满足
must
中的查询 ,即如果没有文档在其content
字段中包含“ricky”,则在结果集中不会有任何匹配项。