I create an index like this:
curl --location --request PUT 'http://127.0.0.1:9200/test/' \
--header 'Content-Type: application/json' \
--data-raw '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"properties" : {
"word" : { "type" : "text" }
}
}
}'
when I create a document:
curl --location --request POST 'http://127.0.0.1:9200/test/_doc/' \
--header 'Content-Type: application/json' \
--data-raw '{ "word":"organic" }'
And finally, search with an intentionally misspelled word:
curl --location --request POST 'http://127.0.0.1:9200/test/_search' \
--header 'Content-Type: application/json' \
--data-raw '{
"suggest": {
"001" : {
"text" : "rganic",
"term" : {
"field" : "word"
}
}
}
}'
The word 'organic' lost the first letter - ES never gives suggestion options for such a mispell (works absolutely fine for any other misspells - 'orgnic', 'oragnc' and 'organi'). What am I missing?
prefix_length
parameter: elastic.co/guide/en/elasticsearch/reference/current/… . It defaults to 1, i.e. at least 1 letter from the beginning of the term has to match. I don't yet have an answer for how to do what you want or whether it's possible with ES' suggest feature, I'll make this a full answer once I know. – Saskatoonhttp://127.0.0.1:9200/test1/_search
but you set up indextest
throughout. I believe you meant to target indextest
rather thantest1
with the search. – Saskatoon