I just digged a bit, and indeed, Hibernate Search 5 skips docvalues on multi-valued fields: hibernate-search/engine/src/main/java/org/hibernate/search/engine/spi/DocumentBuilderIndexedEntity.java at 607de0c510a1f4a9066ba5854cc088a86230e3b3 · hibernate/hibernate-search · GitHub
The problem is really only this line, then:
I can offer a hack to avoid adding doc values in your bridge when the field is multi-valued, but… it’s really just that: a hack. And it might not perform very well, you’ll have to check. Really, you should just upgrade to Hibernate Search 6.
@Override
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions) {
if (value != null) {
+ boolean documentAlreadyHasOneValue = document.getFields().stream().anyMatch(f -> name.equals(f.name()));
final BigInteger integerValue = (BigInteger) value;
final Long indexedValue = integerValue.multiply(storeFactor).longValue();
luceneOptions.addNumericFieldToDocument(name, indexedValue, document);
- document.add(new NumericDocValuesField(name, indexedValue));
+ if (!documentAlreadyHasOneValue) {
+ document.add(new NumericDocValuesField(name, indexedValue));
+ }
}
}
No, I’m afraid includePaths
must be an exhaustive list.