【发布时间】:2018-04-10 09:39:27
【问题描述】:
我正在使用弹性搜索 5.5.2
我正在尝试短语建议器,但无法将其配置为返回索引中已经存在的确切建议。下面给出了我的索引设置、类型映射和短语建议查询。请帮忙。
我的索引设置和类型映射是
PUT test
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"trigram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["shingle"]
}
},
"filter": {
"shingle": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 3
}
}
}
}
},
"mappings": {
"test": {
"properties": {
"title": {
"type": "text",
"fields": {
"trigram": {
"type": "text",
"analyzer": "trigram_analyzer"
}
}
}
}
}
}
}
索引文档使用
POST test/test?refresh=true
{"title": "noble prize"}
我正在使用的短语建议器
POST test/_search
{
"suggest": {
"text": "nobe priz",
"simple_phrase": {
"phrase": {
"field": "title.trigram",
"size": 1,
"gram_size": 3,
"direct_generator": [ {
"field": "title.trigram",
"suggest_mode": "always"
} ],
"highlight": {
"pre_tag": "<em>",
"post_tag": "</em>"
}
}
}
}
}
我得到的结果是
"suggest": {
"simple_phrase": [
{
"text": "nobe priz",
"offset": 0,
"length": 9,
"options": [
{
"text": "noble priz",
"highlighted": "<em>noble</em> priz",
"score": 0.09049256
}
]
}
]
}
我的问题是,对于搜索文本 - “nobe priz” - 为什么我没有获得“noble Prize”作为建议。相反,为什么我只是获得“贵族奖”?
如果我们看到,“贵族奖品”就是我保存的文件。
如果我将大小的值增加到“2”,那么我也不会获得“贵族奖”作为建议之一。
大小为 2,对于搜索文本“nobe priz”,我得到以下响应
"suggest": {
"simple_phrase": [
{
"text": "nobe priz",
"offset": 0,
"length": 9,
"options": [
{
"text": "noble priz",
"highlighted": "<em>nobel</em> priz",
"score": 0.09049256
},
{
"text": "nobe prize",
"highlighted": "nobe <em>prize</em>",
"score": 0.09049256
}
]
}
]
}
我应该怎么做才能获得“贵族奖”作为建议? 请帮忙。
【问题讨论】:
标签: elasticsearch elasticsearch-5