GET /yogurt_insights/_search
{
"query":{"bool":{"must" : [
{ "range" : { "insight_max_date" : { "lte" : "31-12-2019"} } },
{ "range" : { "insight_min_date" : {"gte":"11-10-2019" } }}
]
}
},"aggregations":{
"agg":{"terms":{"field":"topic","order":[{"_count":"desc"}]},"aggregations":{"agg":{"date_histogram":{"field":"insight_max_date","interval":31104000000,"offset":0}}}}}
}
But here I get data aggregated only by topic because of term query, I want it to be aggregated week wise for each topic separately.
The sub-aggregation approach looks right to me, you first aggregate per topic, than per date_histogram, you could also do it the other way (more performant if your index is sorted using the timestamp).
Another alternative is a composite aggregation. The output of that might be less confusing.
I tried following which would solve my purpose, but just a small part remains. Can we set the first and last limit of histogram? I want this histogram to start from min date ("insight_min_date") and end on max date field ("insight_max_date").
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.