沙师弟,师父的充电器掉了

suggestor不支持中文吗?

Elasticsearch | 作者 Morry | 发布于2016年05月04日 | 阅读数:6653

想做搜索提示功能,按官方文档用了suggester,但返回的总是空值
比如一个字段用ik_max_word做analyzer,“西方的华莱士啊,不知道比你们高到哪里去了!”,分词结果
{
"tokens": [
{
"token": "西方",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 0
},
{
"token": "华莱士",
"start_offset": 3,
"end_offset": 6,
"type": "CN_WORD",
"position": 1
},
{
"token": "莱",
"start_offset": 4,
"end_offset": 5,
"type": "CN_WORD",
"position": 2
},
{
"token": "士",
"start_offset": 5,
"end_offset": 6,
"type": "CN_CHAR",
"position": 3
},
{
"token": "啊",
"start_offset": 6,
"end_offset": 7,
"type": "CN_CHAR",
"position": 4
},
{
"token": "不知道",
"start_offset": 8,
"end_offset": 11,
"type": "CN_WORD",
"position": 5
},
{
"token": "不知",
"start_offset": 8,
"end_offset": 10,
"type": "CN_WORD",
"position": 6
},
{
"token": "知道",
"start_offset": 9,
"end_offset": 11,
"type": "CN_WORD",
"position": 7
},
{
"token": "比你",
"start_offset": 11,
"end_offset": 13,
"type": "CN_WORD",
"position": 8
},
{
"token": "你们",
"start_offset": 12,
"end_offset": 14,
"type": "CN_WORD",
"position": 9
},
{
"token": "高",
"start_offset": 14,
"end_offset": 15,
"type": "CN_CHAR",
"position": 10
},
{
"token": "到哪里",
"start_offset": 15,
"end_offset": 18,
"type": "CN_WORD",
"position": 11
},
{
"token": "哪里去",
"start_offset": 16,
"end_offset": 19,
"type": "CN_WORD",
"position": 12
},
{
"token": "哪里",
"start_offset": 16,
"end_offset": 18,
"type": "CN_WORD",
"position": 13
},
{
"token": "里",
"start_offset": 17,
"end_offset": 18,
"type": "CN_WORD",
"position": 14
},
{
"token": "去了",
"start_offset": 18,
"end_offset": 20,
"type": "CN_WORD",
"position": 15
}
]
}

 然后是suggest和结果
GET my/folks/_search
{
"size": 0,
"suggest": {
"text": "东方的华莱土",
"young": {
"term": {
"field": "name"
}
}
}
}

"suggest": {
"young": [
{
"text": "东方",
"offset": 0,
"length": 2,
"options": []
},
{
"text": "华",
"offset": 3,
"length": 1,
"options":
},
{
"text": "莱",
"offset": 4,
"length": 1,
"options":
},
{
"text": "土",
"offset": 5,
"length": 1,
"
已邀请:

Morry

赞同来自:

我自己找到答案了
 
https://discuss.elastic.co/t/w ... ng/79

feiyu

赞同来自:

楼主答案是什么啊,网站打不开
 

1lhbp

赞同来自:

具体怎么实现的,能详细说一下不?

undeg

赞同来自:

联想+纠错

要回复问题请先登录注册