All Superinterfaces:

@Incubating public interface AlternativeBinder extends TypeBinder
The binder that sets up AlternativeValueBridges.

Alternative field bridges solve the problem of mapping one property to multiple fields depending on the value of another property.

One use case is when an entity has text properties whose content is in a different language depending on the value of another property, say language. In that case, you probably want to analyze the text differently depending on the language. This binder solves the problem this way:

  • at bootstrap, declare one index field per language (title_en, title_fr, etc.), assigning a different analyzer to each field;
  • at runtime, put the content of the text property in a different field based on the language.

In order to use this binder, you will need to:

  • annotate a property with AlternativeDiscriminator (e.g. the language property)
  • implement an AlternativeBinderDelegate that will declare the index fields (e.g. one field per language) and create an AlternativeValueBridge. This bridge is responsible for passing the property value to the relevant field at runtime
  • apply the AlternativeBinder to the type hosting the properties (e.g. the type declaring the language property and the multi-language text properties). Generally you will want to create your own annotation for that.
See Also: