Single word suggester or autocomplete single word

Hello Everyone,

Lets consider I have a index for books
And I have following book documents with name

"Manage your time"
"Improvement management skills"
"The making of manager"
"How to manage people"
"Managers guide"

So I type manage in the search

the query output should be
"manage", "management", "manager", "managers"

i.e. I don't want the matching document I just want a autocomplete for the word or word suggester

Hi pranjali,
The new terms_enum api can do this on text fields where the book title has been tokenised into words.

@Mark_Harwood Thank you for the solution.

Do I have to provide any mapping while the index creation?

No, a default mapping will be created for you if you don’t supply one on index creation.

I am getting a empty terms array as a result

{ "_shards": { "total": 1, "successful": 1, "failed": 0 }, "terms": [], "complete": true }

when I try to search "manage"


is there something wrong in my mapping?

My apologies. During development an earlier version of this API supported text fields but the released version doesn't and is mainly for use on keyword fields.

No problem. I even tried with keyword field but it still return an empty array

That would be because the terms_enum API only looks for index matches that start with the provided search string. Keyword fields don't chop document strings into multiple words so the indexed string will be the full value e.g. How to manage people and it doesn't begin with the search string manage

Okay. Thanks

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