# Custom Completion

**URL:** <https://discuss.elastic.co/t/custom-completion/14468>\
**Category:** Elasticsearch\
**Created:** [November 19, 2013, 11:12am UTC](https://discuss.elastic.co/t/custom-completion/14468 "2013-11-19T11:12:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zkidkid](https://avatars.discourse-cdn.com/v4/letter/z/fbc32d/32.png) [@zkidkid](https://discuss.elastic.co/u/zkidkid)\
**Post date:** [November 19, 2013, 11:12am UTC](https://discuss.elastic.co/t/custom-completion/14468/1 "2013-11-19T11:12:57Z")

</div>

Hi,  
I follow step by step 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)

The data I input is:

curl -X PUT 'localhost:9200/music/song/1?refresh=true' -d '{

```
"name" : "Nevermind",

"suggest" : {

    "input": ["Nevermind XYZ", "Nirvana ABC"],

    "output": "Nirvana - Nevermind X",

    "payload" : { "artistId" : 2321 },

    "weight" : 34

}

```

}'

I try to suggest with :

curl -X POST 'localhost:9200/music/\_suggest?pretty' -d '{

```
"song-suggest" : {

    "text" : "nevermind x",

    "completion" : {

        "field" : "suggest"

    }

}

```

}'

Then it's ok.

My current suggest system (which refer from Cleo) could suggest at the  
middle of phrase (not only prefix).

ex: when user suggest for "xy", the suggest system should output "Nirvana -  
Nevermind X" because it match "Nevermind XYZ"

To do it, currently I enrich my data when indexing, ex:

When user index: "Nevermind XYZ ABC DEF"

I will split word and index: "Nevermind XYZ ABC DEF", "XYZ ABC DEF", "ABC  
DEF", "DEF".

I would prefer another way to do it, I have tried by set custom tokenizer  
etc ... but I don't success yet.

Would anyone help me on this situation ?  
I really appreciate your help.

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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Kurt\_Hurtado](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@Kurt\_Hurtado](https://discuss.elastic.co/u/Kurt_Hurtado)\
**Post date:** [November 19, 2013, 9:19pm UTC](https://discuss.elastic.co/t/custom-completion/14468/2 "2013-11-19T21:19:41Z")

</div>

I've always done it that way, by simply adding inputs when indexing... and  
it works great. But I've also wondered if there's a Better Way!  
Thanks,  
Kurt

On Tuesday, November 19, 2013 3:12:57 AM UTC-8, kidkid wrote:

> Hi,  
> I follow step by step here:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html)
> 
> The data I input is:
> 
> curl -X PUT 'localhost:9200/music/song/1?refresh=true' -d '{
> 
> ```
> "name" : "Nevermind",
> 
> "suggest" : {
> 
> "input": ["Nevermind XYZ", "Nirvana ABC"],
> 
> "output": "Nirvana - Nevermind X",
> 
> "payload" : { "artistId" : 2321 },
> 
> "weight" : 34
> 
> }
> 
> ```
> 
> }'
> 
> I try to suggest with :
> 
> curl -X POST 'localhost:9200/music/\_suggest?pretty' -d '{
> 
> ```
> "song-suggest" : {
> 
> "text" : "nevermind x",
> 
> "completion" : {
> 
> "field" : "suggest"
> 
> }
> 
> }
> 
> ```
> 
> }'
> 
> Then it's ok.
> 
> My current suggest system (which refer from Cleo) could suggest at the  
> middle of phrase (not only prefix).
> 
> ex: when user suggest for "xy", the suggest system should output "Nirvana
> 
> - Nevermind X" because it match "Nevermind XYZ"
> 
> To do it, currently I enrich my data when indexing, ex:
> 
> When user index: "Nevermind XYZ ABC DEF"
> 
> I will split word and index: "Nevermind XYZ ABC DEF", "XYZ ABC DEF", "ABC  
> DEF", "DEF".
> 
> I would prefer another way to do it, I have tried by set custom tokenizer  
> etc ... but I don't success yet.
> 
> Would anyone help me on this situation ?  
> I really appreciate your help.
> 
> 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![zkidkid](https://avatars.discourse-cdn.com/v4/letter/z/fbc32d/32.png) [@zkidkid](https://discuss.elastic.co/u/zkidkid)\
**Post date:** [November 20, 2013, 2:59am UTC](https://discuss.elastic.co/t/custom-completion/14468/3 "2013-11-20T02:59:24Z")

</div>

Yes,  
The same here, I (and maybe alot of people) have solved this by enrich data.  
But I still wonder if there has any better way.

As my knowledge, the FST would similar to Adjancency List, which would not  
increase much space in same data -\> so we could enrich data without be  
worry about memory.

Could anyone confirm for this ?

On Tuesday, November 19, 2013 1:19:41 PM UTC-8, Kurt Hurtado wrote:

> I've always done it that way, by simply adding inputs when indexing... and  
> it works great. But I've also wondered if there's a Better Way!  
> Thanks,  
> Kurt
> 
> On Tuesday, November 19, 2013 3:12:57 AM UTC-8, kidkid wrote:
> 
> > Hi,  
> > I follow step by step here:
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html)
> > 
> > The data I input is:
> > 
> > curl -X PUT 'localhost:9200/music/song/1?refresh=true' -d '{
> > 
> > ```
> > "name" : "Nevermind",
> > 
> > "suggest" : {
> > 
> > "input": ["Nevermind XYZ", "Nirvana ABC"],
> > 
> > "output": "Nirvana - Nevermind X",
> > 
> > "payload" : { "artistId" : 2321 },
> > 
> > "weight" : 34
> > 
> > }
> > 
> > ```
> > 
> > }'
> > 
> > I try to suggest with :
> > 
> > curl -X POST 'localhost:9200/music/\_suggest?pretty' -d '{
> > 
> > ```
> > "song-suggest" : {
> > 
> > "text" : "nevermind x",
> > 
> > "completion" : {
> > 
> > "field" : "suggest"
> > 
> > }
> > 
> > }
> > 
> > ```
> > 
> > }'
> > 
> > Then it's ok.
> > 
> > My current suggest system (which refer from Cleo) could suggest at the  
> > middle of phrase (not only prefix).
> > 
> > ex: when user suggest for "xy", the suggest system should output "Nirvana
> > 
> > - Nevermind X" because it match "Nevermind XYZ"
> > 
> > To do it, currently I enrich my data when indexing, ex:
> > 
> > When user index: "Nevermind XYZ ABC DEF"
> > 
> > I will split word and index: "Nevermind XYZ ABC DEF", "XYZ ABC DEF", "ABC  
> > DEF", "DEF".
> > 
> > I would prefer another way to do it, I have tried by set custom tokenizer  
> > etc ... but I don't success yet.
> > 
> > Would anyone help me on this situation ?  
> > I really appreciate your help.
> > 
> > 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:06am UTC](https://discuss.elastic.co/t/custom-completion/14468/4 "2017-07-06T02:06:07Z")

</div>


