Get distinct result by using multi_match and suggestion

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" -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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/859b067e-f2cb-4cc4-beef-bba547a85906%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.