几天前,我遇到了这个“问题”。match_phrase
我在我的索引中运行一个查询。一切都如预期的那样,直到我对多个词的名词进行了相同的搜索(在我使用单个词的名词之前,例如:大学)。我犯了一个拼写错误并且搜索不起作用(未找到),如果我删除了一个单词(假设拼写正确的单词),则搜索工作(找到)。
这里有我做的例子:
设置
PUT index1
{
"mappings": {
"myType": {
"properties": {
"field1": {
"type": "string",
"analyzer": "standard"
}
}
}
}
}
POST index1/myType/1
{
"field1": "Commercial Banks"
}
案例一:单名词检索
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
查询时没有找到文档?有什么我想念的吗?这些结果只是对我所知道的产生怀疑。我是否错误地使用了模糊搜索?我不确定这是否是一个问题,或者我是不理解这种行为的人。
非常感谢您阅读我的问题。我希望你能帮我解决这个问题。