Custom field bridges which provide sortable fields don't have their doc values added automatically, because we prevent that explicitly in org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.addSortFieldDocValues(Document, PropertyMetadata, float, Object). That behavior is documented:
Fields added through class-level bridges or custom field-level bridges (when not using the default field name) cannot
be marked as sortable by means of the `@SortableField` annotation. Instead the field bridge itself has to add the
required doc value fields, in addition to the document fields it adds. Furthermore such bridge needs to implement the
`MetadataProvidingFieldBridge` interface which defines a method `configureFieldMetadata()` for marking the fields
created by this bridge as sortable:
We should do something to make that easier.
One solution would be to provide methods in LuceneOptions to add sortable fields (internally, we'd add the docvalues along with the standard field).
Another solution would be to simply remove the requirement for field bridges to provide the doc values field themselves: we could do that for them. It seems it would be easy enough as long as the custom field bridge adds a standard field (IntField, DoubleField, etc.) with the value to sort on.
However, I just checked: the sortable() thing in custom field bridges has been added in 5.5.1 / 5.6.0: HSEARCH-2021. So the second solution would mean introducing breaking changes...
One solution would be to provide methods in LuceneOptions
We're going to need this specific solution, so that Infinispan Query can override things dynamically. It can't provide the full metadata in advance.