# Get distinct result by using multi\_match and suggestion

**URL:** <https://discuss.elastic.co/t/get-distinct-result-by-using-multi-match-and-suggestion/19458>\
**Category:** Elasticsearch\
**Created:** [August 26, 2014, 11:17am UTC](https://discuss.elastic.co/t/get-distinct-result-by-using-multi-match-and-suggestion/19458 "2014-08-26T11:17:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramy](https://avatars.discourse-cdn.com/v4/letter/r/8491ac/32.png) [@Ramy](https://discuss.elastic.co/u/Ramy)\
**Post date:** [August 26, 2014, 11:17am UTC](https://discuss.elastic.co/t/get-distinct-result-by-using-multi-match-and-suggestion/19458/1 "2014-08-26T11:17:52Z")

</div>

Is there a way to solve the following problem?

I have created a search field with suggestions functionality. The user is  
able to search for names, categories, etc. These fields are mapped like:

{  
"settings": {  
"analysis": {  
"analyzer": {  
"_autocomplete_": {  
"type": "custom",  
"tokenizer": "_edge\_ngram\_tokenizer_",  
"filter": ["lowercase"]  
}  
},  
"tokenizer": {  
"_edge\_ngram\_tokenizer_": {  
"type": "edgeNGram",  
"min\_gram": 1,  
"max\_gram": 20,  
"token\_chars": ["letter", "digit"]  
}  
}  
}  
},  
"mappings": {  
"my\_type": {  
"dynamic": "strict",  
"properties": {  
"id": {  
"type": "long"  
},  
"_name_": {  
"type": "string",  
"analyzer": "english",  
"fields": {  
_"autocomplete": {_

- 

```
               "type": "string", *

```

- 

```
               "index_analyzer": "autocomplete", *

```

- 

```
               "search_analyzer": "standard"*

```

- 

```
             }*
          }
      },
      "*category*": {
          "type": "string",
          "analyzer": "english",
          "fields": {
            *"autocomplete": {*

```

- 

```
               "type": "string", *

```

- 

```
               "index_analyzer": "autocomplete", *

```

- 

```
               "search_analyzer": "standard"*

```

- 

```
             }*
          }
      },

```

...

Now when i do something like this:  
curl -XGET "[http://localhost:9200/my\_index/my\_type/\_search](http://localhost:9200/my_index/my_type/_search)" -d'  
{  
"\_source": false,  
"query": {  
"multi\_match": {  
"query": "pet",  
"fields": [  
"\*._autocomplete_"  
]  
}  
}  
}'

I get results like these:

- Peter
- Peter
- Peter
- Petra
- Petra  
etc.

_How can I reduce (distinct) the results on server side like these?_

- Peter
- Petra
- etc.

thx, Ramy

--  
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/859b067e-f2cb-4cc4-beef-bba547a85906%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/859b067e-f2cb-4cc4-beef-bba547a85906%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:06am UTC](https://discuss.elastic.co/t/get-distinct-result-by-using-multi-match-and-suggestion/19458/2 "2017-07-06T01:06:31Z")

</div>

Closed on July 6, 2017, 1:06am UTC


