Class HighlightProjectionBinder
java.lang.Object
org.hibernate.search.mapper.pojo.search.definition.binding.builtin.HighlightProjectionBinder
- All Implemented Interfaces:
ProjectionBinder
Binds a constructor parameter to a projection to highlights,
i.e. sequences of text that matched the query, extracted from the given field's value.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(ProjectionBindingContext context) Binds a constructor parameter to a projection.static HighlightProjectionBinder
create()
Creates aHighlightProjectionBinder
to be passed toMethodParameterMappingStep.projection(ProjectionBinder)
.static HighlightProjectionBinder
Creates aFieldProjectionBinder
to be passed toMethodParameterMappingStep.projection(ProjectionBinder)
.highlighter
(String highlighterName)
-
Method Details
-
create
Creates aHighlightProjectionBinder
to be passed toMethodParameterMappingStep.projection(ProjectionBinder)
.This method requires the projection constructor class to be compiled with the
-parameters
flag to infer the field path from the name of the constructor parameter being bound. If this compiler flag is not used, usecreate(String)
instead and pass the field path explicitly.- Returns:
- The binder.
-
create
Creates aFieldProjectionBinder
to be passed toMethodParameterMappingStep.projection(ProjectionBinder)
.- Parameters:
fieldPath
- The path to the index field whose highlights will be extracted. Whennull
, defaults to the name of the constructor parameter being bound, if it can be retrieved (requires the class to be compiled with the-parameters
flag; otherwise a nullfieldPath
will lead to a failure).- Returns:
- The binder.
-
highlighter
- Parameters:
highlighterName
- The name of a highlighterdefined on the query
, ornull
to use the default highlighter.- Returns:
this
, for method chaining.- See Also:
-
bind
Description copied from interface:ProjectionBinder
Binds a constructor parameter to a projection.The context passed in parameter provides various information about the constructor parameter being bound. Implementations are expected to take advantage of that information and to call one of the
definition*(...)
methods on the context to set the projection.- Specified by:
bind
in interfaceProjectionBinder
- Parameters:
context
- A context object providing information about the constructor parameter being bound, and expecting a call to one of itsdefinition*(...)
methods.
-