# Completion suggester get Exact matched token

**URL:** <https://discuss.elastic.co/t/completion-suggester-get-exact-matched-token/23216>\
**Category:** Elasticsearch\
**Created:** [April 13, 2015, 6:23pm UTC](https://discuss.elastic.co/t/completion-suggester-get-exact-matched-token/23216 "2015-04-13T18:23:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ap1](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Ap1](https://discuss.elastic.co/u/Ap1)\
**Post date:** [April 13, 2015, 6:23pm UTC](https://discuss.elastic.co/t/completion-suggester-get-exact-matched-token/23216/1 "2015-04-13T18:23:09Z")

</div>

How do you get the exact matched token from the completion suggester ?

eg.  
{  
"id" : "ID1",  
"name" : "AAA BBB CCCC DDD EEE FFFF GGG HHHHH IIII JJJJ KKK LLL 999  
888",  
"suggest" : {  
"input":  
["AAA","BBB","CCCC","DDD","EEE","US","California","Framework","IIII","JJJJ","KKK","LLL","999","888"],  
"output":   
"payload" : {  
"id" : "ID1",  
"name" : text  
}  
}

So if a user types cali, the output that needs to be returned to the user  
is the matched token "California" instead of the complete string or id.

Thanks

--  
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/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [April 14, 2015, 5:33am UTC](https://discuss.elastic.co/t/completion-suggester-get-exact-matched-token/23216/2 "2015-04-14T05:33:23Z")

</div>

Hello AP ,

Yes that is how it works.  
If the input text ( cali ) is the affix of any of the input then the output  
would be returned.

```
  {
    "id" : "ID1",
    "name" : "AAA BBB CCCC DDD EEE FFFF GGG HHHHH IIII JJJJ KKK LLL 999

```

888",  
"suggest" : {  
"input":  
["AAA","BBB","CCCC","DDD","EEE","US","California","Framework","IIII","JJJJ","KKK","LLL","999","888"],  
"output": _"California City"_  
"payload" : {  
"id" : "ID1",  
"name" : text  
}  
}

In this example , if the input string is cali or fra or ee or US , it will  
all match to "Califronia City" and this output text and payload would be  
returned.

Thanks  
Vineeth Mohan,  
Elasticsearch consultant,  
[qbox.io](http://qbox.io) ( Elasticsearch service provider [http://qbox.io/](http://qbox.io/))

On Mon, Apr 13, 2015 at 11:53 PM, Ap [usc90909@gmail.com](mailto:usc90909@gmail.com) wrote:

> How do you get the exact matched token from the completion suggester ?
> 
> eg.  
> {  
> "id" : "ID1",  
> "name" : "AAA BBB CCCC DDD EEE FFFF GGG HHHHH IIII JJJJ KKK LLL  
> 999 888",  
> "suggest" : {  
> "input":  
> ["AAA","BBB","CCCC","DDD","EEE","US","California","Framework","IIII","JJJJ","KKK","LLL","999","888"],  
> "output":   
> "payload" : {  
> "id" : "ID1",  
> "name" : text  
> }  
> }
> 
> So if a user types cali, the output that needs to be returned to the user  
> is the matched token "California" instead of the complete string or id.
> 
> Thanks
> 
> --  
> 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/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7b04ed89-814d-48e4-8666-c4f24f45186d%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/CAGdPd5%3D2fvicp6MPfTLV-HkL-NtHE7d7cQBJXoz9MK%2Btz6uJgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3D2fvicp6MPfTLV-HkL-NtHE7d7cQBJXoz9MK%2Btz6uJgg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ap1](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Ap1](https://discuss.elastic.co/u/Ap1)\
**Post date:** [April 14, 2015, 5:37am UTC](https://discuss.elastic.co/t/completion-suggester-get-exact-matched-token/23216/3 "2015-04-14T05:37:36Z")

</div>

Hi Vineeth,

Thanks for the response.

I actually want the output to be flexible ( returning matched tokens)  
instead of a hard coded vaue.

eg. For "input": ["AAA","BBB","CCCC","DDD","EEE","US","California","  
Framework","IIII","JJJJ","KKK","LLL","999","888"]

if "Cali" was searched then output should be "California"  
if "Frame" was searched then output should be "Framework"

On Mon, Apr 13, 2015 at 10:33 PM, vineeth mohan [vm.vineethmohan@gmail.com](mailto:vm.vineethmohan@gmail.com)  
wrote:

> Hello AP ,
> 
> Yes that is how it works.  
> If the input text ( cali ) is the affix of any of the input then the  
> output would be returned.
> 
> ```
> {
> "id" : "ID1",
> "name" : "AAA BBB CCCC DDD EEE FFFF GGG HHHHH IIII JJJJ KKK LLL
> 
> ```
> 
> 999 888",  
> "suggest" : {  
> "input":  
> ["AAA","BBB","CCCC","DDD","EEE","US","California","Framework","IIII","JJJJ","KKK","LLL","999","888"],  
> "output": _"California City"_  
> "payload" : {  
> "id" : "ID1",  
> "name" : text  
> }  
> }
> 
> In this example , if the input string is cali or fra or ee or US , it will  
> all match to "Califronia City" and this output text and payload would be  
> returned.
> 
> Thanks  
> Vineeth Mohan,  
> Elasticsearch consultant,  
> [qbox.io](http://qbox.io) ( Elasticsearch service provider [http://qbox.io/](http://qbox.io/))
> 
> On Mon, Apr 13, 2015 at 11:53 PM, Ap [usc90909@gmail.com](mailto:usc90909@gmail.com) wrote:
> 
> > How do you get the exact matched token from the completion suggester ?
> > 
> > eg.  
> > {  
> > "id" : "ID1",  
> > "name" : "AAA BBB CCCC DDD EEE FFFF GGG HHHHH IIII JJJJ KKK LLL  
> > 999 888",  
> > "suggest" : {  
> > "input":  
> > ["AAA","BBB","CCCC","DDD","EEE","US","California","Framework","IIII","JJJJ","KKK","LLL","999","888"],  
> > "output":   
> > "payload" : {  
> > "id" : "ID1",  
> > "name" : text  
> > }  
> > }
> > 
> > So if a user types cali, the output that needs to be returned to the user  
> > is the matched token "California" instead of the complete string or id.
> > 
> > Thanks
> > 
> > --  
> > 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/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/7b04ed89-814d-48e4-8666-c4f24f45186d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7b04ed89-814d-48e4-8666-c4f24f45186d%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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/x0UIaDVLX0Q/unsubscribe](https://groups.google.com/d/topic/elasticsearch/x0UIaDVLX0Q/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/CAGdPd5%3D2fvicp6MPfTLV-HkL-NtHE7d7cQBJXoz9MK%2Btz6uJgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3D2fvicp6MPfTLV-HkL-NtHE7d7cQBJXoz9MK%2Btz6uJgg%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3D2fvicp6MPfTLV-HkL-NtHE7d7cQBJXoz9MK%2Btz6uJgg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3D2fvicp6MPfTLV-HkL-NtHE7d7cQBJXoz9MK%2Btz6uJgg%40mail.gmail.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/CAFJXNN6Dp90CvNpuw5twFG%3DFzPUKxWEHYYjLdkMCXMr8qZXixQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFJXNN6Dp90CvNpuw5twFG%3DFzPUKxWEHYYjLdkMCXMr8qZXixQ%40mail.gmail.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, 12:19am UTC](https://discuss.elastic.co/t/completion-suggester-get-exact-matched-token/23216/4 "2017-07-06T00:19:59Z")

</div>


