不为失败找理由,要为成功找方法。

ik match_phrase 无法匹配

Elasticsearch | 作者 cht | 发布于2019年03月19日 | 阅读数:2162

文件名 “PD1728_A_1”,创建索引和搜索都使用ik_max_word, 但是使用搜索词 PD1728 无法匹配到。通过 _analyze
{"analyzer":"ik_max_word","text":"PD1728_A_1.1.1"}
{
"tokens": [
{
"token": "pd1728_a_1.1.1",
"start_offset": 0,
"end_offset": 14,
"type": "LETTER",
"position": 0
},
{
"token": "pd",
"start_offset": 0,
"end_offset": 2,
"type": "ENGLISH",
"position": 1
},
{
"token": "1728",
"start_offset": 2,
"end_offset": 6,
"type": "ARABIC",
"position": 2
},
{
"token": "a",
"start_offset": 7,
"end_offset": 8,
"type": "ENGLISH",
"position": 3
},
{
"token": "1.1.1",
"start_offset": 9,
"end_offset": 14,
"type": "ARABIC",
"position": 4
}
],
}

{"analyzer":"ik_max_word","text":"PD1728"}
{
"tokens": [
{
"token": "pd1728",
"start_offset": 0,
"end_offset": 6,
"type": "LETTER",
"position": 0
},
{
"token": "pd",
"start_offset": 0,
"end_offset": 2,
"type": "ENGLISH",
"position": 1
},
{
"token": "1728",
"start_offset": 2,
"end_offset": 6,
"type": "ARABIC",
"position": 2
}
],
}
已邀请:

rochy - rochy_he

赞同来自:

上述的肯定匹配不到,因为原来的分词结果里面没有 pd1728,所以无法匹配到
 
可使用前缀查询试试

bellengao - 博客: https://www.jianshu.com/u/e0088e3e2127

赞同来自:

搜索时不使用ik_max_word, 然后使用match就可以吧

lxq - 93年,java

赞同来自:

这个查询按照match_phase的语法,应该是可以查到的

要回复问题请先登录注册