Reputation: 63
I have indexed some documents like below
{
"height" : "165"
"weight": "102-kgs"
}
Now I need to aggregate the weight field,but since it is given as "102-kgs",results in erroneous aggregation. Any way to break and get the weight only?
Upvotes: 1
Views: 37
Reputation: 19273
You should be employing scripts for these kind of operations. In this case the following script would get you the required results:
{
"query": {
"match_all": {}
},
"aggs": {
"weights": {
"terms": {
"field": "weight",
"script": "_value.split('-')[0]"
}
}
}
}
Upvotes: 1