multifield search
好吧,让我们来复习下filter,有个重要的filter叫term,term又可以同时搜索多个值。多值搜索不是多字段搜索{
“query”:{
"filtered":{
"filter":{
"terms":{
"title":["1", "2", "3"]
}
}
}
}
}
GET /_search如果把should单独不用bool包裹会产生什么影响呢
{
"query": {
"bool": {
"should": [
{ "match": { "title": "War and Peace" }},
{ "match": { "author": "Leo Tolstoy" }},
{ "bool": {
"should": [
{ "match": { "translator": "Constance Garnett" }},
{ "match": { "translator": "Louise Maude" }}
]
}}
]
}
}
}
GET /_search
{
"query": {
"bool": {
"should": [
{ "match": { "title": "War and Peace" }},
{ "match": { "author": "Leo Tolstoy" }},
{ "match": { "translator": "Constance Garnett" }},
{ "match": { "translator": "Louise Maude" }}
]
}
}
}
The answer lies in how the score is calculated. The bool
query runs each match
query, adds their scores together, then multiplies by the number of matching clauses, and divides by the total number of clauses. Each clause at the same level has the same weight. In the preceding query, the bool