几天前,我得到了这个“问题”。我在索引中运行match_phrase
查询。一切都如预期,直到我用多个单词名词进行同样的搜索(在我使用单个单词名词之前,例如:大学)。如果我删除了一个单词(比如说拼写正确的单词),那么搜索工作(找到)会导致拼写错误,并且搜索不起作用(未找到)。match_phrase查询中的模糊行为
在这里有我做的例子:
的设置
PUT index1
{
"mappings": {
"myType": {
"properties": {
"field1": {
"type": "string",
"analyzer": "standard"
}
}
}
}
}
POST index1/myType/1
{
"field1": "Commercial Banks"
}
案例1:单名词搜索
GET index1/myType/_search
{
"query": {
"match": {
"field1": {
"type": "phrase",
"query": "comersial",
"fuzziness": "AUTO"
}
}
}
}
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.19178303,
"hits": [
{
"_index": "index1",
"_type": "myType",
"_id": "1",
"_score": 0.19178303,
"_source": {
"field1": "Commercial Banks"
}
}
]
}
}
案例2:多个名词搜索
GET index1/myType/_search
{
"query": {
"match": {
"field1": {
"type": "phrase",
"query": "comersial banks",
"fuzziness": "AUTO"
}
}
}
}
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
因此,在第二种情况下,为什么在执行match_phrase
查询时找不到文档?有什么我失踪? 这些结果只是让我怀疑我所知道的。 我使用模糊搜索吗?我不确定这是否是一个问题,或者我是不了解这种行为的人。
非常感谢提前阅读我的问题。我希望你能帮助我。