What is the difference between suggest_mode missing and always?

elasticsearch version 6.4.0

I am a newcomer to elasticsearch. I have some doubts about term suggest .I know suggest_mode has possible values(missing, popular, always) and i understand the 'missing', but can't understand the 'always'.

below is my mappings and data

PUT books_info
{
"mappings": {
"IT":{
"properties": {
"id":{
"type":"long"
},
"title":{
"type":"text"
}
}
}
}
}

post books_info/IT
{
"id":"1",
"title":"html books"
}

post books_info/IT
{
"id":"2",
"title":"java books"
}

post books_info/IT
{
"id":"3",
"title":"c++ books"
}

post books_info/IT
{
"id":"4",
"title":"android books"
}

below is my suggest search

post books_info/_search
{
"suggest" : {
"my-suggestion" : {
"text" : "androids",
"term" : {
"field" : "title",
"suggest_mode":"always"
}
}
}
}

search result :
{
"took": 17,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": 0,
"hits": []
},
"suggest": {
"my-suggestion": [
{
"text": "androids",
"offset": 0,
"length": 8,
"options": [
{
"text": "android",
"score": 0.85714287,
"freq": 1
}
]
}
]
}
}

My question is when i use 'androids' text the search will suggest 'android', but when i use 'android' text the search will suggest nothing.I also test missing mode and find the always mode as same as missing mode.

The docs says : always - Suggest any matching suggestions based on terms in the suggest text, so i think when i provide 'android' text the search should suggest 'android'.

Have i misunderstand the always mode ???, please help me explain it

Hi , i test many times and search on google 、stackoverflow、github, finally find the elasticsearch issues, this is why missing mode and always mode always return the same result.

Now i also understand term suggest , the suggest search only suggest for spell error text term.If you provide a exact text term that exist in index, the suggest search will return nothing.

for example :
two docs
1、title:android
2、title:html
if you use 'android' to suggest search,you will get nothing ,but if you use 'androids' you will get 'android'

below example explained what is the difference between missing and always:
two docs
1、title: android
2、title: androids
If you set suggest_mode : missing and use 'android' text to suggest search, you get nothing, because 'android' exist in index.
If you set suggest_mode: always and use 'android' text to suggest search, you get suggestion 'androids'.

sorry for my bad english , i wish these can help others

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.