此内容没有您所选择的语言版本。
4.4.2. Dynamic Index Time Boosting
The
@Boost
annotation defines a static boost factor that is independent of the state of the indexed entity at runtime. However, in some cases the boost factor may depend on the actual state of the entity. In this case, use the @DynamicBoost
annotation together with an accompanying custom BoostStrategy
.
@Boost
and @DynamicBoost
annotations can both be used in relation to an entity, and all defined boost factors are cumulative. The @DynamicBoost
can be placed at either class or field level.
In the following example, a dynamic boost is defined on class level specifying
VIPBoostStrategy
as implementation of the BoostStrategy
interface used at indexing time. Depending on the annotation placement, either the whole entity is passed to the defineBoost
method or only the annotated field/property value. The passed object must be cast to the correct type.
Example 4.8. Dynamic boost example
In the provided example all indexed values of a VIP would be twice the importance of the values of a non-VIP.
Note
The specified
BoostStrategy
implementation must define a public no argument constructor.