I want the aggregated count of state such that, only one latest document sorted by created_at and candidate_id is there in response.
Expected response
{
key: "a",
doc_count: 1 // instead of 3. as for candidate 43, 44 doc with `state` `b` "created_at": "2020-05-06" so it latest. so state "a" will be ignored
},
{
key: "b",
doc_count: 2
}
So what I want is that in query I should only see one document per candidate_idsorted by created_atdesc
So that aggregation will work on a data set without state "a" of candidate 43, 44
If i use cardinality with candidate_id and agg on state. then count of a comes as 3.
how to do this? Is there a way to sort with created_at and filter data on one document per candidate_id
The best approach would be to use a Transform job to to make the data set entity centric, then you'll be able to get the different stats using a terms aggregation.
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.