I have an aggregate query to make which buckets the city name of a country. The query (which I make in sense) is as below:
GET test/_search
{
"query" : {
"bool" : {
"must" : {
"match" : {
"name.autocomplete" : {
"query" : "new yo",
"type" : "boolean"
}
}
},
"must_not" : {
"term" : {
"source" : "old"
}
}
}
},
"aggregations" : {
"city_name" : {
"terms" : {
"field" : "cityname.raw",
"min_doc_count" : 1
},
"aggregations" : {
"country_name" : {
"terms" : {
"field" : "countryname.raw"
}
}
}
}
}
}
Now in the documents New Yorkoccurs two time one with an extra trailing space. The aggregation result which I get is as below:
{
"key": "New York",
"doc_count": 1,
"city_name": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "United States of America",
"doc_count": 1
}
]
}
},
{
"key": "New York ",
"doc_count": 1,
"city_name": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "United States of America",
"doc_count": 1
}
]
}
}
I need the both New York to be treated the same. Is there any way I can query that I get both of them in the same group. Any things which trims the trailing spaces will do I guess. Could not find anything though. Thanks