Elasticsearch 模糊查询的结果少于预期
Fewer than Expected Results from Elasticsearch's Fuzzy Query
我在使用 elasticsearch 模糊查询时遇到一些奇怪的行为,我不知道自己做错了什么。
这些是我索引中的名称:
"hits": [
{
"name": "bbbb"
"name": "abab"
"name": "abbb"
"name": "aaaa"
}
}
]
但是这个查询假设 return 所有四个元素,return 只给我 "abab" 和 "aaaa"。
POST /test/_search?pretty
{
"size": 10,
"query": {
"fuzzy": {
"name": {
"value": "aaaa",
"fuzziness": 4
}
}
}
}
名称字段映射为字符串类型。附带一问,设置not_analyzed映射到字段会影响模糊查询结果吗?
基于Elasticsearch's Common Options - Fuzziness documentation referenced at the end of Fuzzy Query documentation,对于字符串字段,fuzziness 参数似乎只采用以下值之一:0、1、2、AUTO、0.0...0.1。该部分的最后一块作为注释:
Note: in all APIs except for the Fuzzy Like This Query, the maximum allowed edit distance is 2.
如您所见,除此之外的任何内容似乎都在 2 的编辑距离处被限制。这都是针对更高版本的 Elasticsearch,因为 0.90 的文档有点不同。
我在使用 elasticsearch 模糊查询时遇到一些奇怪的行为,我不知道自己做错了什么。
这些是我索引中的名称:
"hits": [
{
"name": "bbbb"
"name": "abab"
"name": "abbb"
"name": "aaaa"
}
}
]
但是这个查询假设 return 所有四个元素,return 只给我 "abab" 和 "aaaa"。
POST /test/_search?pretty
{
"size": 10,
"query": {
"fuzzy": {
"name": {
"value": "aaaa",
"fuzziness": 4
}
}
}
}
名称字段映射为字符串类型。附带一问,设置not_analyzed映射到字段会影响模糊查询结果吗?
基于Elasticsearch's Common Options - Fuzziness documentation referenced at the end of Fuzzy Query documentation,对于字符串字段,fuzziness 参数似乎只采用以下值之一:0、1、2、AUTO、0.0...0.1。该部分的最后一块作为注释:
Note: in all APIs except for the Fuzzy Like This Query, the maximum allowed edit distance is 2.
如您所见,除此之外的任何内容似乎都在 2 的编辑距离处被限制。这都是针对更高版本的 Elasticsearch,因为 0.90 的文档有点不同。