# Completion suggester for search terms instead of documents

**URL:** <https://discuss.elastic.co/t/completion-suggester-for-search-terms-instead-of-documents/100250>\
**Category:** Elasticsearch\
**Created:** [September 12, 2017, 7:17pm UTC](https://discuss.elastic.co/t/completion-suggester-for-search-terms-instead-of-documents/100250 "2017-09-12T19:17:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![uprise10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uprise10/32/12759_2.png) [@uprise10](https://discuss.elastic.co/u/uprise10)\
**Post date:** [September 12, 2017, 7:17pm UTC](https://discuss.elastic.co/t/completion-suggester-for-search-terms-instead-of-documents/100250/1 "2017-09-12T19:17:57Z")

</div>

When using the Completion Suggester, the results you get are regular documents. I get that 🙂

However, we'd like to receive search phrase suggestions instead of direct results (the documents). To achieve this we thought that we could store several corresponding "search phrases" to the documents, and provide this as the "suggest" field when indexing.

In general this works, however the Suggester returns now all documents which contains these matches search phrases, which causes duplicate phrases.

For instance when having 2 documents:

- Document A is a blue "BMW X3", which has "blue car" attached as "suggest" phrase.
- Document B is a blue "Volvo V60", which also has "blue car" attached as "suggest" phrase.

When searching for "blue", the Suggester now returns both documents, and in fact this is a duplicate result we don't want.

Is the above setup the way to go, and how could we filter out these duplicates? Or do we need a different approach?

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [September 15, 2017, 7:50am UTC](https://discuss.elastic.co/t/completion-suggester-for-search-terms-instead-of-documents/100250/2 "2017-09-15T07:50:13Z")

</div>

We added a new option called `skip_duplicates` for the completion suggester:  
[https://www.elastic.co/guide/en/elasticsearch/reference/master/search-suggesters-completion.html#skip\_duplicates](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-suggesters-completion.html#skip_duplicates)

This option when set is able to remove the duplicated documents (document matching with a suggestion already returned in a previous doc). It will be available in es 6.1.

---

<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:** [October 13, 2017, 7:50am UTC](https://discuss.elastic.co/t/completion-suggester-for-search-terms-instead-of-documents/100250/3 "2017-10-13T07:50:15Z")

</div>

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