Elasticsearch - 使用模糊编辑距离是不准确的

时间:2017-09-10 03:13:38

标签: elasticsearch

我使用的是ES 5.5,我的要求是在匹配字段时允许最多两次编辑。

在ES中,我的值为 124456788 ,查询的格式为 123456789

"fuzzy": {
                            "idkey": {
                                "value": **"123456789"**,
                                "fuzziness": "20"

                            }
                        }

据我所知,这两个数字之间的编辑距离是2。但它甚至与模糊属性不匹配为20。

我做了一个解释api电话,这就是我所看到的

"description": "no match on required clause (((idkey:012345789)^0.7777778 (idkey:012346789)^0.7777778 (idkey:013456789)^0.7777778 (idkey:023456789)^0.8888889 (idkey:102345678)^0.7777778 (idkey:112345678)^0.7777778 (idkey:113456789)^0.8888889 (idkey:120456589)^0.7777778 (idkey:121345678)^0.7777778 (idkey:122345678)^0.7777778 (idkey:122345679)^0.7777778 (idkey:122456789)^0.8888889 (idkey:123006789)^0.7777778 (idkey:123045678)^0.7777778 (idkey:123096789)^0.7777778 (idkey:123106789)^0.7777778 (idkey:123145678)^0.7777778 (idkey:123146789)^0.7777778 (idkey:123226789)^0.7777778 (idkey:123256789)^0.8888889 (idkey:123345678)^0.7777778 (idkey:123345689)^0.7777778 (idkey:123346789)^0.7777778 (idkey:123406784)^0.7777778 (idkey:123415678)^0.7777778 (idkey:123435678)^0.7777778 (idkey:123446789)^0.8888889 (idkey:123453789)^0.8888889 (idkey:123454789)^0.8888889 (idkey:123455789)^0.8888889 (idkey:123456289)^0.8888889 (idkey:123456489)^0.8888889 (idkey:123456709)^0.8888889 (idkey:123456779)^0.8888889 (idkey:123456780)^0.8888889 (idkey:123456781)^0.8888889 (idkey:123456783)^0.8888889 (idkey:123456785)^0.8888889 (idkey:123456786)^0.8888889 (idkey:123456787)^0.8888889 (idkey:123456889)^0.8888889 (idkey:123457789)^0.8888889 (idkey:123466789)^0.8888889 (idkey:123496789)^0.8888889 (idkey:123556789)^0.8888889 (idkey:126456789)^0.8888889 (idkey:223456789)^0.8888889 (idkey:423456789)^0.8888889 (idkey:623456789)^0.8888889 (idkey:723456789)^0.8888889)^5.0)",

我期望匹配的值是124456788但是ES查询在内部没有将其转换为模糊查询中可能的匹配参数之一。

我是否需要使用不同的ES方法来完成这项工作?

1 个答案:

答案 0 :(得分:0)

这是一个简单的索引和搜索。

PUT /myIndex/type1/1
{
    "key":"123456789",
    "name":"test"
}

GET /myIndex/_search
{
    "query": {
        "fuzzy": {
            "key": {
                "value": "124456799",
                "fuzziness": 2
            }
        }
    }
}

它总是与给定的键匹配。 fuzziness值2或更高可以。