Update-by-query: No mapping found for [id] in order to sort on


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?

Hi @davysteegen,

Welcome to the community! Have you tried using the missing_values option to see if that helps you with this error?


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.


Do you happen to have any update on this? :slight_smile:

Hi @davysteegen,

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.

Hi @carly.richmond

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 :wink:

No worries at all @davysteegen. I'm glad you found a workaround. Thanks for sharing!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.