# How can i get unique suggestions without duplicates when i use completion suggester?

**URL:** <https://discuss.elastic.co/t/how-can-i-get-unique-suggestions-without-duplicates-when-i-use-completion-suggester/74767>\
**Category:** Elasticsearch\
**Created:** [February 11, 2017, 4:14pm UTC](https://discuss.elastic.co/t/how-can-i-get-unique-suggestions-without-duplicates-when-i-use-completion-suggester/74767 "2017-02-11T16:14:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adinarayana\_Murthy](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Adinarayana\_Murthy](https://discuss.elastic.co/u/Adinarayana_Murthy)\
**Post date:** [February 11, 2017, 4:14pm UTC](https://discuss.elastic.co/t/how-can-i-get-unique-suggestions-without-duplicates-when-i-use-completion-suggester/74767/1 "2017-02-11T16:14:55Z")

</div>

Hi

I am using elastic 5.1.1 in my environment . currently i am using the completion suggester on filed name post\_hashtags . i am getting response as below for prefx "inv"

eg:  
Req:

```
POST hashtag/_search?pretty&&filter_path=suggest.hash-suggest.options.text,suggest.hash-suggest.options._source
{"_source":["post_hashtags"],

    "suggest": {
        "hash-suggest" : {
            "prefix" : "inv",
            "completion" : {
                "field" : "post_hashtags"
            }
        }
    } 

```

Response :

```
{
  "suggest": {
    "hash-suggest": [
      {
        "options": [
          {
            "text": "invalid",
            "_source": {
              "post_hashtags": [
                "invalid"
              ]
            }
          },
          {
            "text": "invalid",
            "_source": {
              "post_hashtags": [
                "invalid",
                "coment_me",
                "daya"
              ]
            }
          }
        ]
      }
    ]
  }
}

```

Here "invalid" is returned twice because it is also a input string for same field "post\_hashtags" in other document .  
Problems is if same "invalid" input string present in 1000 documents in same index . i will get 1000 duplicated  
suggestions

Can i apply aggregation kind of work on the field of type completion ?

Is there any way i can get unique suggestion instead of duplicated text field , even though if i have same input string given to a particular field in multiple documents of same index ?

---

<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:** [March 11, 2017, 4:15pm UTC](https://discuss.elastic.co/t/how-can-i-get-unique-suggestions-without-duplicates-when-i-use-completion-suggester/74767/2 "2017-03-11T16:15:09Z")

</div>

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