enter image description hereI have to find the data of last 10 days and then aggregate the result by grouping on one column.
below is my code:
function countHits(){
client.search({
//size:0,
body:{
"aggs":{
"distinct_value":{
"date_range":
{
"field":"@timestamp",
"format":"dd-MM-yyyy",
"ranges":
[
{"to":"now/d"},
{"from":"now-10d/d"}
]
}
}
},"aggs":{
"distinct_value" :{
"date_histogram":{
"field" :"@timestamp",
"interval":"day"
}
}
}
}
}).then(function(response){
console.log(response);
}
)
the first aggregation gives two buckets "key:"-11-07-2016"" and key:"01-07-2016-"and their doc_counts and then second aggregation aggregates on the whole result . but i want to put the second aggregation on the result getting from only key key:"01-07-2016-*"
can someone help me on this.