Actually, i am trying to implement the following MySQL query in elasticsearch.
SELECT SUM(FIELD_1) FROM (SELECT FIELD_1 FROM TABLE GROUP BY FIELD_2) AS UNIQUE_TABLE
I tried the following query in elasticsearch
GET index/_search
{
"size": 0,
"query": {},
"aggs": {
"unique_twitter": {
"terms": {
"size": 1000,
"field": "field_2"
},
"aggs": {
"max": {
"max": {
"field": "field_1"
}
}
}
},
"count": {
"sum_bucket": {
"buckets_path": "unique_twitter>max"
}
}
}
}
The problem with the following query, I have to give the size of the first aggregation to make it work. I want it to work without specifying the size of the aggregation.
Thanks in advance !!