# Is there any way to implement autofill and autogenerate results feature in Elasticsearch

**URL:** <https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501>\
**Category:** Elasticsearch\
**Created:** [June 1, 2016, 2:12am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501 "2016-06-01T02:12:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 1, 2016, 2:12am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/1 "2016-06-01T02:12:16Z")

</div>

Hi,

I'm trying to do a document search application using Elastic search(NEST client)[I'm indexing the word documents as an attachment as of now].  
I would like to know if there is way to do an auto fill feature using ES.

Something like "As in when i type some text in search text box, it start returning results based on that few text. Similar to google."

TIA

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 1, 2016, 4:45am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/2 "2016-06-01T04:45:28Z")

</div>

You can use the suggest API or use edge ngrams based analyzers for that.

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 1, 2016, 8:05am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/3 "2016-06-01T08:05:32Z")

</div>

Hi David.  
Thanks for the suggestion.  
I was reading through Completion suggester (\> [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html) & [https://www.elastic.co/blog/you-complete-me](https://www.elastic.co/blog/you-complete-me)). While reading through, I got a doubt. While using this suggester, while indexing the document,do we have to give the output of the suggestion also? And also while working on attachments, how can I implement this suggester? TIA  
TIA

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 1, 2016, 9:34am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/4 "2016-06-01T09:34:58Z")

</div>

Yeah. It probably won't work with attachments unless you do the text extraction on your side with Tika directly.

So you'd probably better use ngrams.

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 1, 2016, 9:42am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/5 "2016-06-01T09:42:08Z")

</div>

if I'm not wrong , ngrams are used for a different purpose.  
for eg: lets say I'm indexing a word elastic, then it will index as e,el,ela,elas,elast,elasti, elastic. So when I try to search "el" it will give me this result. Isnt it?

But my purpose is to only suggest the as I type the keyword and on search button click, it should find as per the search query and the keyword. Can ngrams be used in this case also?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 1, 2016, 11:52am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/6 "2016-06-01T11:52:05Z")

</div>

indeed. But once you get the 1st 10 more relevant documents, you can extract from their `_source` any field you want and display it to the user?  
Or run an aggregation on a given non analyzed field and display that to the user?

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 2, 2016, 12:42am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/7 "2016-06-02T00:42:08Z")

</div>

Thanks david. But I'm already using "english" analyzer on the attachment's content field. So can this(ngram) be joined along with it? (like separate index analyzer and search analyzer).. I presume this one (the english analyzer is search analyzer in this case)

![](https://us1.discourse-cdn.com/elastic/original/2X/7/77dcbc7639c8bc23d8cef8ba0ea382be754e3e25.png)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 2, 2016, 4:59am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/8 "2016-06-02T04:59:03Z")

</div>

I think we support multi fields. So you could may be use that to index as well with ngrams.

I tried to do IIRC on scrutmydocs project but it was giving not so good results on the content field. Was making more sense on title.

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 2, 2016, 6:07am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/9 "2016-06-02T06:07:52Z")

</div>

thanks for the info david.. Yeah if im using ngrams i will be using it on title field where as english analyzer on the content field while search. does that make sense? am i thinking in the right direction?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 2, 2016, 6:58am UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/10 "2016-06-02T06:58:47Z")

</div>

Yes. But again (I think I already wrote that), using mapper attachments is not the ideal thing to do.

I definitely prefer:

- Doing the extraction in my application with Tika, create the JSON document exactly as I want, apply analyzers, multifield, copy\_to, whatever feature you want.

or

- Wait for 5.0 and use ingest-attachment plugin.

`mapper-attachments` plugin will be removed in the future, probably in 5.1 or 6.0.  
It's already [marked as deprecated](https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-attachments.html).

---

<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:** [July 5, 2017, 10:47pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-implement-autofill-and-autogenerate-results-feature-in-elasticsearch/51501/11 "2017-07-05T22:47:01Z")

</div>


