We are in the process of migrating from Elasticsearch 2.3 to 8.6. One thing I noticed is that the sorting in the update-by-query API now only allows to provide a comma separated list of field/sort direction combos. In the past this was an object where you could also provide an unmapped type in case not all documents in the index have the field where you want to apply the sorting on.
We are no getting the No mapping found for [field] in order to sort on error when the index is empty or not all documents have the sorted field.
So my question is, is there a workaround for this issue?
Thank you for the feedback! I have already been looking into that as well but it turns out that the update-by-query API handles sorting slightly different than the normal search API.
When looking at the docs, it is stated that it should be provided with key/direction pairs (e.g: name:asc,lastName:desc). There does not seem to be a way to provide complex objects as the sorting is passed as a request parameter to the update-by-query API.
We are using the Java client library and that one only accepts a List of String for sorting.
Sadly not I've been on vacation. Since you've using the Java client I've added the language-clients tag to see if that helps with a response. If I find anything else I'll let you know.
I just wanted to let you know that in the meantime I implemented a workaround. I first do a count on the index to see if there is at least one document before doing the actual update-by-query call. This makes sure that I never get the error regarding the unmapped field. So at least we are not blocked by this anymore
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.