Solr sort on multivalue field produces Bytesref error in multi-shard env

72 Views Asked by At

Solr 8.11 (in SolrCloud mode) returns a 500 error when querying with sort parameter sort=field("RECORD_DATE") asc.

The error message is:

class java.lang.String cannot be cast to class org.apache.lucene.util.BytesRef (java.lang.String is in module java.base of loader 'bootstrap'; org.apache.lucene.util.BytesRef is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @7f69d591)

RECORD_DATE is a multivalued field. I don't have problems when using a "simple" field such as score for sorting.

What is strange is that the error only occurs in a multi-shard environment. In a single-shard environment, there is no error!

1

There are 1 best solutions below

0
Juuso Ohtonen On

I could not get RECORD_DATE sort work reliably. Apparently, it did not work reliably even with single shard Solr! So, I switched the sort field from RECORD_DATE to _version_.

Benefits of using _version_:

  1. single value field
  2. always exists
  3. sort order as desired - Solr document creation time