Sorting multivalued dates is incorrect with large number of shards

I have an index with 40 shards. When I sort a field with date type and it is multivalued, then I get the results sorted in incorrect order.

This is how the sort is built:

"PDate"{
"order" : "desc",
"missing" : "_last",
"mode" : "min"
}

The results all get as sort value -9223372036854775808

I do not get this when I have an smaller index with a few shards. Then the results are ordered correct.

Is there a limitation (or even a bug) on sorting of multivalued fields with a large number of shards?

Hi,

Did you have the same documents as you had with 40 shards?

As far as I know, no.

It looks like the documents that match your query have no PDate value, thus elasticsearch internally uses the Long.MIN_VALUE to sort them because missing is set to _last and order to desc. Using Long.MIN_VALUE helps to "push" documents with no PDate value to the end of the list but in your case only documents without PDate match your search query.

No, it's a much smaller subset.

I see that also the _missing mode value gets ignored. I retrieve the docs with the PDate field in the source, and then I see its value(s) present, and even fields with missing values get shown in the top. The sorting value is for each and every hit this:

"sort":[-9223372036854775808]

Sorry, I found the resolution. The field was of nested type and I did not see this. My apologies.