# Single word suggester or autocomplete single word

**URL:** <https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754>\
**Category:** Elasticsearch\
**Created:** [December 2, 2021, 11:15am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754 "2021-12-02T11:15:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranjali\_dhumal](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@pranjali\_dhumal](https://discuss.elastic.co/u/pranjali_dhumal)\
**Post date:** [December 2, 2021, 11:15am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/1 "2021-12-02T11:15:11Z")

</div>

Hello Everyone,

Problem:  
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

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [December 2, 2021, 11:21am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/2 "2021-12-02T11:21:56Z")

</div>

Hi pranjali,  
The new [terms\_enum](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html) api can do this on text fields where the book title has been tokenised into words.

---

<div class="post-metadata">

**Author:** ![pranjali\_dhumal](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@pranjali\_dhumal](https://discuss.elastic.co/u/pranjali_dhumal)\
**Post date:** [December 3, 2021, 6:19am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/3 "2021-12-03T06:19:56Z")

</div>

@Mark_Harwood Thank you for the solution.

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

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [December 3, 2021, 8:19am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/4 "2021-12-03T08:19:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pranjali\_dhumal](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@pranjali\_dhumal](https://discuss.elastic.co/u/pranjali_dhumal)\
**Post date:** [December 3, 2021, 8:47am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/5 "2021-12-03T08:47:59Z")

</div>

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"

![image](https://us1.discourse-cdn.com/elastic/original/3X/2/9/29d5c7d8330417daf9ce838e6152dc955f10db02.png)

is there something wrong in my mapping?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [December 6, 2021, 9:47am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/6 "2021-12-06T09:47:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pranjali\_dhumal](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@pranjali\_dhumal](https://discuss.elastic.co/u/pranjali_dhumal)\
**Post date:** [December 6, 2021, 10:27am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/7 "2021-12-06T10:27:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [December 6, 2021, 10:56am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/8 "2021-12-06T10:56:11Z")

</div>

> [@pranjali\_dhumal](#):
>
> 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`

---

<div class="post-metadata">

**Author:** ![pranjali\_dhumal](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@pranjali\_dhumal](https://discuss.elastic.co/u/pranjali_dhumal)\
**Post date:** [December 7, 2021, 6:27am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/9 "2021-12-07T06:27:20Z")

</div>

Okay. Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 4, 2022, 6:27am UTC](https://discuss.elastic.co/t/single-word-suggester-or-autocomplete-single-word/290754/10 "2022-01-04T06:27:55Z")

</div>

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