ProgLearner ProgLearner - 11 months ago 140
ASP.NET (C#) Question

Elastic search 5.0 duplicate removal/optimisation

From ES 5.0 Fielddata is disabled on text fields by default., How I could remove duplicates/ achieve the same result with existing settings i.e. when field data is disabled on query below?

{
"aggs": {
"query": {
"terms": {
"field": "name"
}
,
"aggs": {
"top": {
"top_hits": {
"size": 1
}
}


}
}
},
"size": 0,
"query": {

"multi_match": {
"query": "laura",
"operator": "OR",
"fields": [

"name"

]
}
}
}

Answer Source

You would have to enable fielddata on text fields for ES 5.x. Use it with caution as it consumes lot of heap space.

Update your mapping with

PUT your_index/_mapping/your_type
{
  "properties": {
    "name": { 
      "type":     "text",
      "fielddata": true
    }
  }
}

and then run the query.