gpt4 book ai didi

elasticsearch - 短语建议器 Elasticsearch 不纠正两个词

转载 作者:行者123 更新时间:2023-12-04 06:15:51 28 4
gpt4 key购买 nike

我有以下映射到我的短语建议者:

{
"settings": {
"analysis": {
"analyzer": {
"suggests_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding",
"shingle_filter"
],
"type": "custom"
}
},
"filter": {
"shingle_filter": {
"min_shingle_size": 2,
"max_shingle_size": 6,
"type": "shingle"
}
}
}
},
"mappings": {
"sample_data": {
"properties": {
"name": {
"type": "string",
"analyzer": "suggests_analyzer"
}
}
}
}
}

我的索引中有“肺癌”、“结直肠癌”、“乳腺癌”。但是,当我查询一个拼写错误的查询时,当我使用整理功能时,两个词都被拼错,如“lhng cancar”,返回零结果。我的示例查询如下。

{
"suggest": {
"text": "lhng cancar",
"simple_phrase": {
"phrase": {
"field": "name",
"size": 5,
"real_word_error_likelihood": 0.95,
"max_errors": 0.5,
"direct_generator": [
{
"field": "name",
"suggest_mode": "always",
"size": 5

}
],
"collate": {
"query": {
"inline": {
"match_phrase": {
"{{field_name}}": "{{suggestion}}"
}
}
},
"params": {
"field_name": "name"
},
"prune": false
}
}
}
},
"size": 0
}

上述查询的响应是:

{
"took": 17,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1868381,
"max_score": 0,
"hits": []
},
"suggest": {
"simple_phrase": [
{
"text": "lhng cancar",
"offset": 0,
"length": 11,
"options": []
}
]
}
}

需要在查询中做哪些更改才能在建议中获得预期结果“肺癌”?

最佳答案

您必须将 max_errors 提高到 0.8 或更多。

这里给出了相同的答案 ElasticSearch - Phrase Suggestor

关于elasticsearch - 短语建议器 Elasticsearch 不纠正两个词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42090508/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com