Hello,
I have documents representing user requests, each document contains user_id and timestamp.
A simple date histogram aggregation generates the number of daily users like this
{
"aggs": {
"2": {
"date_histogram": {
"field": "@timestamp",
"interval": "1d",
"min_doc_count": 0
},
"aggs": {
"1": {
"cardinality": {
"field": "user_id.keyword"
}
}
}
}
},
"size": 0
}
This will generate a graph for total daily users.
I want to make graphs for new users and returning users.
For new users : Filter the buckets to not count documents which contains user_id that is already counted in a previous bucket.
For returning users : Filter the buckets to count only documents which contains user_id that is already counted in a previous bucket.
How can I do this ?