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"
}
}
}]
}
}
}
- According to Improving search relevance with boolean queries
must
meansand
,should
meansor
- In the query above
must
andshould
("and" and "or") are on the same level.
- So what does this bool query mean ?
- Does
should
contributes here to the final score (ifmust
query dosn't take any place) ?
CodePudding user response:
must should is only about search relevance improvement and not just and or
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 theirheader
field.The query in
must
MUST be met, i.e. if no document contain "ricky" in theircontent
field, there won't be any match in the result set.