we’re currently evaluating Hibernate-Search 6 as a replacement for our self-made elasticsearch-framework. Currently I’m struggling with one specific feature which seems to be not available (although it’s quite a basic one).
What do I have to do in order to get mappings with multi-fields? In case i annotate a field with different annotations (e.g. FullTextField + KeywordField), I get two fields for it (instead of being able to work with the multi-field feature).
Example:
The following field
public String getFirstName() {...}
should be annotated in such a way that I get the following mapping for it:
Multi-fields are not supported yet, but as you mentioned there is the workaround of defining multiple index fields using separate annotations. Hibernate Search will just push the data to the index twice, in separate index fields.
Is there a particular reason you need multi-fields? As far as I know you will benefit from the same features when searching, just with a different field path.
You’re right: This issue can be resolved by declaring multiple fields instead of using the multi-field feature.
But this would also mean that it’s necessary to add the same value multiple times (once per annotation) to the source of the document which leads to unnecessary additional network traffic. But I guess one can live with that.
IMHO I also prefer the multi-field feature as it keeps the index cleaner and much more readable as I immediately see that 1) the field exists and 2) which analyzations are available for that single field. But I guess that’s very subjective