I get one entry (the earliest by timestamp) that matches the desired service_id. However, I would like to retrieve the most recent matching entry. I do:
But then I get the most recent entry regardless of service_id. Sometimes the service_id is "foo", but sometimes it's "bar", sometimes ... It's as if Elasticsearch completely ignores the "match" when I add the "sort" part. It doesn't help if I put the "sort" before the query, between the query and size, or at the end after the size.
Am I doing anything wrong? Could someone please help?
Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.
A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.
it returns the entry with service_id "this-is-my-bar" (which does have a later timestamp, but I'm asking for entries that match service_id "this-is-my-foo").
The unexpected behavior does not happen if the "service_id"s are just "foo" and "bar", but it does happen if they have a common string at the start (which is also the case in my real data).
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.