疲劳是最舒适的枕头,努力工作吧。

elasticsearch ik 中文分词后,命中数据很诡异

Elasticsearch | 作者 weiwosuoai | 发布于2018年04月19日 | 阅读数:4756

我想测试下 ik 分词后的检索效果,于是创建一个索引:
 
{
"settings": {
"number_of_replicas": 0
},
"mappings": {
"question": {
"dynamic": false,
"properties": {
"title": {
"type": "text",
"index": "analyzed",
"analyzer": "ik_smart",
"search_analyzer": "ik_smart"
},
"desc": {
"type": "text",
"index": "analyzed",
"analyzer": "ik_smart",
"search_analyzer": "ik_smart"
}
}
}
}
}

然后我插入了一条测试数据:
 

13624814-8945-4453-854B-5BC47D5EDC23.png

 
测试查询:
 

4A03B616-7E10-4B81-BAFD-CA3E41A29BC2.png

 
发现并没有命中数据,但是 hits total 数值为 1,却没有数据返回,于是我试了下标题标题为 docker 容器内的系统时间不正确 的分词结果:
 
{
"tokens": [
{
"token": "docker",
"start_offset": 0,
"end_offset": 6,
"type": "ENGLISH",
"position": 0
},
{
"token": "容器",
"start_offset": 7,
"end_offset": 9,
"type": "CN_WORD",
"position": 1
},
{
"token": "内",
"start_offset": 9,
"end_offset": 10,
"type": "CN_CHAR",
"position": 2
},
{
"token": "的",
"start_offset": 10,
"end_offset": 11,
"type": "CN_CHAR",
"position": 3
},
{
"token": "系统",
"start_offset": 11,
"end_offset": 13,
"type": "CN_WORD",
"position": 4
},
{
"token": "时间",
"start_offset": 13,
"end_offset": 15,
"type": "CN_WORD",
"position": 5
},
{
"token": "不正确",
"start_offset": 15,
"end_offset": 18,
"type": "CN_WORD",
"position": 6
}
]
}
分词看上去并没有什么问题,分词中是有 docker 关键字的,让后我又加了条 title 为 容器内的系统时间不正确 docker 的记录:
 

1524108111176.jpg

 
让后再次查询:
 

B2F023B6-6D25-4B46-99D2-B50AE45C3859.png

 
之前的那条数据能够被查询出来,很诡异。。。,初次接触 elasticsearch, 不知道是啥情况,难道是我哪里设置不正确,我用的版本是 5.6.1
 
有知道的前辈能帮帮忙么。
 

 
已邀请:

要回复问题请先登录注册