我有以下映射到我的短语建议者:
{
"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": []
}
]
}
}
在查询中需要进行哪些更改,以便获得预期的结果"肺癌"在建议?
答案 0 :(得分:2)
您必须将max_errors
提升至0.8或更高。
这里给出了相同的答案 ElasticSearch - Phrase Suggestor
答案 1 :(得分:2)
提高max_errors: 2
的参数解决了我的问题。