弹性查询只接受 4 个字符

Elastic Query accepting only 4 characters

我是 运行 elastic search 版本 7.2 中的一个术语查询,当我的查询中有 4 个字符时,它可以工作,如果我添加或删除任何字符,它就不起作用。

工作查询:

{
"query": {
    "bool": {
        "must": [{
                "terms": {
                    "GEP_PN": ["6207"]
                }
            },
            {
                "match": {
                    "GEP_MN.keyword": "SKF"
                }
            }
        ]
    }
}
}

结果:

查询失败:

它没有失败,它没有为您的 search-term 找到结果,请注意文档中提到的 terms query are not analyzed

Returns documents that contain one or more exact terms in a provided field.

请提供您的索引的映射,如果它使用 text 字段而您没有使用 custom-analyzer,它将使用 standard analyzer,这将在 [=14= 上拆分标记],因此您的条款查询与倒排索引中存在的标记不匹配。

请参阅 analyze API o/p 为您的 search-term,它解释了可能的 root-cause。

{
    "text" : "6207-R"
}

代币

{
    "tokens": [
        {
            "token": "6207",
            "start_offset": 0,
            "end_offset": 4,
            "type": "<NUM>",
            "position": 0
        },
        {
            "token": "r",
            "start_offset": 5,
            "end_offset": 6,
            "type": "<ALPHANUM>",
            "position": 1
        }
    ]
}