# Autocomplete returns - can you get input word that was matched?

**URL:** <https://discuss.elastic.co/t/autocomplete-returns-can-you-get-input-word-that-was-matched/16878>\
**Category:** Elasticsearch\
**Created:** [April 8, 2014, 11:44pm UTC](https://discuss.elastic.co/t/autocomplete-returns-can-you-get-input-word-that-was-matched/16878 "2014-04-08T23:44:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![redrubia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redrubia/32/1554_2.png) [@redrubia](https://discuss.elastic.co/u/redrubia)\
**Post date:** [April 8, 2014, 11:44pm UTC](https://discuss.elastic.co/t/autocomplete-returns-can-you-get-input-word-that-was-matched/16878/1 "2014-04-08T23:44:03Z")

</div>

From autocompleter, usually you return the matched word, the output. Is  
there any way to return exactly what you matched on?

For example if you look at the completion info here[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html) you'll  
see the input for a doc is a list ["Nevermind", "Nirvana"] . But how do  
we know if we complete on 'Nevermind' or 'Nirvana'? Arguably you can say if  
the input is 'Ne' assume Nevermind, and similarly for 'Ni' for Nirvana, but  
what about when these inputs get more complex? You want to know the exact  
input completed on, so you can say to the user 'Your input matches xxx',  
but its 'xxx'

My main reason for asking is I have created a company index, and well there  
are mergers. For example someone may type Merrill Lynch to get back Bank of  
America as their output. So when they type 'Merr' to get 'Bank of America',  
it lacks consistency for the user. I'd like to improve upon this, so I can  
say ''Merrill Lynch', did you mean 'Bank of America'?'

A long winded way of doing this would be to then look up the document in  
the index, and determine which input was used... but this is extremely long  
winded. Also secondly you could place every variant in a separate document,  
so input is just a string. But this means you'd quite possibly have  
multiple docs being returned with the same name, to show up multiple times  
in the response (not ideal).

Any ideas on how to do this? or if the functionality is there?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0d866dcd-ba1e-4b56-b76b-9a01d891a759%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d866dcd-ba1e-4b56-b76b-9a01d891a759%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 9, 2014, 7:38am UTC](https://discuss.elastic.co/t/autocomplete-returns-can-you-get-input-word-that-was-matched/16878/2 "2014-04-09T07:38:29Z")

</div>

Hey,

it is possible to not specify an output, then every input becomes the  
output. However, this does not allow to create a unified output, which, I  
think, is the whole purpose. There is no way to find out, which of the  
input actually has matched currently.

Trying to have very good outputs like, "Bank of America (before: Merryll  
Lynch)" might be an idea...

--Alex

On Wed, Apr 9, 2014 at 1:44 AM, redrubia [ruby.childs1@gmail.com](mailto:ruby.childs1@gmail.com) wrote:

> From autocompleter, usually you return the matched word, the output. Is  
> there any way to return exactly what you matched on?
> 
> For example if you look at the completion info here[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html) you'll  
> see the input for a doc is a list ["Nevermind", "Nirvana"] . But how do  
> we know if we complete on 'Nevermind' or 'Nirvana'? Arguably you can say if  
> the input is 'Ne' assume Nevermind, and similarly for 'Ni' for Nirvana,  
> but what about when these inputs get more complex? You want to know the  
> exact input completed on, so you can say to the user 'Your input matches  
> xxx', but its 'xxx'
> 
> My main reason for asking is I have created a company index, and well  
> there are mergers. For example someone may type Merrill Lynch to get back  
> Bank of America as their output. So when they type 'Merr' to get 'Bank of  
> America', it lacks consistency for the user. I'd like to improve upon this,  
> so I can say ''Merrill Lynch', did you mean 'Bank of America'?'
> 
> A long winded way of doing this would be to then look up the document in  
> the index, and determine which input was used... but this is extremely long  
> winded. Also secondly you could place every variant in a separate document,  
> so input is just a string. But this means you'd quite possibly have  
> multiple docs being returned with the same name, to show up multiple times  
> in the response (not ideal).
> 
> Any ideas on how to do this? or if the functionality is there?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/0d866dcd-ba1e-4b56-b76b-9a01d891a759%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d866dcd-ba1e-4b56-b76b-9a01d891a759%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/0d866dcd-ba1e-4b56-b76b-9a01d891a759%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0d866dcd-ba1e-4b56-b76b-9a01d891a759%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM\_YDiREKYxnjRaeugZhTAgGeO4yK0zC%2BXLFZ-QiYtsZjA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_YDiREKYxnjRaeugZhTAgGeO4yK0zC%2BXLFZ-QiYtsZjA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![redrubia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redrubia/32/1554_2.png) [@redrubia](https://discuss.elastic.co/u/redrubia)\
**Post date:** [April 9, 2014, 1:50pm UTC](https://discuss.elastic.co/t/autocomplete-returns-can-you-get-input-word-that-was-matched/16878/3 "2014-04-09T13:50:18Z")

</div>

Hi Alex,

Thanks for your response. Yes I agree, autocomplete is to find a unified  
name, but it is also extremely handy to know what the matched word was. You  
can technically infer this from adding the doc id within pay load, and thus  
look it up afterwards but this is long winded. One main advantage of  
knowing what the match is, is for analytics, such as if you want to see  
what variant was most commonly used to then make it a doc in its own right.

Would be good to see if this functionality can be build into ES to see the  
exact matches and the unified output result.

Thanks

Ruby

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5c04f395-6725-4de0-8b7a-4bc1796f7342%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5c04f395-6725-4de0-8b7a-4bc1796f7342%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:37am UTC](https://discuss.elastic.co/t/autocomplete-returns-can-you-get-input-word-that-was-matched/16878/4 "2017-07-06T01:37:17Z")

</div>


