Hi,
I'm trying to create a query to count string and aggregate based on occurence but I can't figure out how. I have a collection of documents containing only a time field and string. Here's the simple mapping:
"document":
{ "time": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"name": {
"index": "not_analyzed",
"type": "string"
}
}
The name can contains the same values once or more, I would like to know how many "names" are present once, how many are present twice and so on for every day. Is it possible with only one query?
I tried with this query:
{
"aggs":{
"3":{
"terms":{
"field":"name"
},
"aggs":{
"2":{
"date_histogram":{
"interval":"1d",
"field":"time"
}
}
}
}
}
}
I can only obtain a list of names with their occurence in the period like:
DAY 1
A: 2 times
B: 1 times
C: 2 times
But I wold like to obtain somthing like:
DAY 1
100 names are present 1 times
50 names are present 2 times
1 names is present 3 times
Thanks!