I'm trying to perform a search that returns the most recent document per unique value of field "unique_hash". I'm using a "field collapse" aggregation, like so:
As you can see, I am sorting the inner hits on "created_at", using a descending sort. This field is mapped to a "date" type. However, this does not return the latest document for each value of unique hash, and appears to take the earliest instead. Swapping "asc" for "desc" has no effect on the results returned.
Hey @Mark_Harwood. Unfortunately I cannot - I have found the source of my error, and it was not Elasticsearch. I have some minimal ORM that grabbed the wrong part of the response, when I inspected the raw response it became clear that the inner_hits part of the result contained the expected document.
Thanks for your help, sorry for wasting your time!
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.