我在多个字段中使用多个术语进行了多匹配查询:
{
"multi_match": {
"query": ["екатеринбург", "тимирязева"],
"fields": [
"admin0_name^1.0",
"admin0_alternate_names^0.95",
"local_admin_name^0.6",
"locality_name^1.2",
"locality_alternate_names^1.15",
"neighborhood_name^0.3",
"street_name^1.4",
"housenumber^1.4",
"housenumber_exact^1.5",
"name.text^2.0"],
"type": "most_fields",
"_name": "main_search_query"
}
}
字词екатеринбург
应与locality_name
匹配,而тимирязева
应与street_name
和name.text
匹配。
但查询解释显示我只匹配тимирязева
:
1.0168997 = (MATCH) product of:
5.0844984 = (MATCH) sum of:
3.4778461 = (MATCH) weight(name.text:тимирязева^2.0 in 233899) [PerFieldSimilarity], result of:
3.4778461 = score(doc=233899,freq=2.0), product of:
0.39484683 = queryWeight, product of:
2.0 = boost
9.965216 = idf(docFreq=184, maxDocs=1447823)
0.019811254 = queryNorm
8.808089 = fieldWeight in 233899, product of:
1.4142135 = tf(freq=2.0), with freq of:
2.0 = termFreq=2.0
9.965216 = idf(docFreq=184, maxDocs=1447823)
0.625 = fieldNorm(doc=233899)
1.6066521 = (MATCH) weight(street_name:тимирязева^1.4 in 233899) [PerFieldSimilarity], result of:
1.6066521 = score(doc=233899,freq=2.0), product of:
0.22453468 = queryWeight, product of:
1.4 = boost
8.095495 = idf(docFreq=1199, maxDocs=1447823)
0.019811254 = queryNorm
7.1554747 = fieldWeight in 233899, product of:
1.4142135 = tf(freq=2.0), with freq of:
2.0 = termFreq=2.0
8.095495 = idf(docFreq=1199, maxDocs=1447823)
0.625 = fieldNorm(doc=233899)
0.2 = coord(2/10)
为了确保екатеринбург
与locality_name
匹配,我将该查询与术语查询结合起来作为bool查询的必要部分。它匹配。
如果我将查询数组中的术语顺序更改为["тимирязева", "екатеринбург"]
情况更改为完全相反,екатеринбург
匹配locality_name
但тимирязева
不匹配{{ 1}}。
看起来只有street_name
考虑的最后一个字词。
N.b。我使用相当旧版本的ES:1.4是一个错误还是我得到multi_match
错误的方式?
我可以遵循解决方法:使用查询作为字符串而不是查询,但我很感兴趣为什么预先处理的方法失败。
答案 0 :(得分:1)
试试这个,可能对你有帮助: -
Query_string比multi_match更强大。link
{
"query": {
"query_string": {
"fields" : ["admin0_name*",
"admin0_alternate_names*",
"local_admin_name*",
"locality_name*",
"locality_alternate_names*",
"neighborhood_name*",
"street_name*",
"housenumber*",
"housenumber_exact*",
"name.text*"] ,
"query": "*екатеринбург*" OR "*тимирязева*"
}
}
}
以下是我的分析,query_string在部分搜索link
中的功能如何更强大