我很确定这与词干有关,而且我不确定我需要更改哪些内容才能获得拼写建议以返回整个单词。
设置如下:
ELASTICSEARCH_INDEX_SETTINGS = {
'settings': {
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "standard",
"filter": ["standard", "lowercase", "stop_words", "cm_snow"]
},
"ngram_analyzer": {
"type": "custom",
"tokenizer": "lowercase",
"filter": ["haystack_ngram"]
},
"edgengram_analyzer": {
"type": "custom",
"tokenizer": "lowercase",
"filter": ["haystack_edgengram"]
}
},
"tokenizer": {
"haystack_ngram_tokenizer": {
"type": "nGram",
"min_gram": 3,
"max_gram": 15,
},
"haystack_edgengram_tokenizer": {
"type": "edgeNGram",
"min_gram": 2,
"max_gram": 15,
"side": "front"
}
},
"filter": {
"haystack_ngram": {
"type": "nGram",
"min_gram": 3,
"max_gram": 15
},
"haystack_edgengram": {
"type": "edgeNGram",
"min_gram": 2,
"max_gram": 15
},
"cm_snow": {
"type": "snowball",
"language": "English"
},
"stop_words": {
"type": "stop",
"ignore_case": True,
"stopwords": STOP_WORDS
}
}
}
}
}
如果我对 Elasticsearch 进行以下查询:
curl -XPOST 'localhost:9200/listing/_suggest' -d '{
"my-suggestion" : {
"text" : "table",
"term" : {
"field" : "text"
}
}
}'
我回来了:
{"text":"tabl","offset":0,"length":5,"options":[]}
为什么结果是“表格”,即使是拼写正确的单词?