Class DelegatingSearchSortFactory<PDF extends SearchPredicateFactory>
- java.lang.Object
-
- org.hibernate.search.engine.search.sort.dsl.spi.DelegatingSearchSortFactory<PDF>
-
- All Implemented Interfaces:
ExtendedSearchSortFactory<PDF>
,SearchSortFactory
public class DelegatingSearchSortFactory<PDF extends SearchPredicateFactory> extends Object implements ExtendedSearchSortFactory<PDF>
A delegatingSearchSortFactory
.Mainly useful when implementing a
SearchSortFactoryExtension
.
-
-
Constructor Summary
Constructors Constructor Description DelegatingSearchSortFactory(SearchSortFactory delegate, SearchSortDslContext<?,? extends PDF> dslContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompositeSortComponentsStep<?>
composite()
Order by a sort composed of several elements.SortThenStep
composite(Consumer<? super CompositeSortComponentsStep<?>> elementContributor)
Order by a sort composed of several elements, which will be defined by the given consumer.protected SearchSortFactory
delegate()
DistanceSortOptionsStep<?,PDF>
distance(String absoluteFieldPath, GeoPoint location)
Order elements by the distance from the location stored in the specified field to the location specified.SearchSortFactoryExtensionIfSupportedStep
extension()
Create a DSL step allowing multiple attempts to apply extensions one after the other, failing only if none of the extensions is supported.<T> T
extension(SearchSortFactoryExtension<T> extension)
Extend the current factory with the given extension, resulting in an extended factory offering different types of sorts.FieldSortOptionsStep<?,PDF>
field(String absoluteFieldPath)
Order elements by the value of a specific field.SortThenStep
indexOrder()
Order elements by their internal index order.ScoreSortOptionsStep<?>
score()
Order elements by their relevance score.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.search.engine.search.sort.dsl.ExtendedSearchSortFactory
distance
-
-
-
-
Constructor Detail
-
DelegatingSearchSortFactory
public DelegatingSearchSortFactory(SearchSortFactory delegate, SearchSortDslContext<?,? extends PDF> dslContext)
-
-
Method Detail
-
score
public ScoreSortOptionsStep<?> score()
Description copied from interface:SearchSortFactory
Order elements by their relevance score.The default order is descending, i.e. higher scores come first.
- Specified by:
score
in interfaceSearchSortFactory
- Returns:
- A DSL step where the "score" sort can be defined in more details.
-
indexOrder
public SortThenStep indexOrder()
Description copied from interface:SearchSortFactory
Order elements by their internal index order.- Specified by:
indexOrder
in interfaceSearchSortFactory
- Returns:
- A DSL step where the "index order" sort can be defined in more details.
-
field
public FieldSortOptionsStep<?,PDF> field(String absoluteFieldPath)
Description copied from interface:SearchSortFactory
Order elements by the value of a specific field.The default order is ascending.
- Specified by:
field
in interfaceExtendedSearchSortFactory<PDF extends SearchPredicateFactory>
- Specified by:
field
in interfaceSearchSortFactory
- Parameters:
absoluteFieldPath
- The absolute path of the index field to sort by- Returns:
- A DSL step where the "field" sort can be defined in more details.
-
distance
public DistanceSortOptionsStep<?,PDF> distance(String absoluteFieldPath, GeoPoint location)
Description copied from interface:SearchSortFactory
Order elements by the distance from the location stored in the specified field to the location specified.The default order is ascending.
- Specified by:
distance
in interfaceExtendedSearchSortFactory<PDF extends SearchPredicateFactory>
- Specified by:
distance
in interfaceSearchSortFactory
- Parameters:
absoluteFieldPath
- The absolute path of the indexed location field to sort by.location
- The location to which we want to compute the distance.- Returns:
- A DSL step where the "distance" sort can be defined in more details.
-
composite
public CompositeSortComponentsStep<?> composite()
Description copied from interface:SearchSortFactory
Order by a sort composed of several elements.Note that, in general, calling this method is not necessary as you can chain sorts by calling
SortThenStep.then()
. This method is mainly useful to mix imperative and declarative style when building sorts. SeeSearchSortFactory.composite(Consumer)
- Specified by:
composite
in interfaceSearchSortFactory
- Returns:
- A DSL step where the "composite" sort can be defined in more details.
-
composite
public SortThenStep composite(Consumer<? super CompositeSortComponentsStep<?>> elementContributor)
Description copied from interface:SearchSortFactory
Order by a sort composed of several elements, which will be defined by the given consumer.Best used with lambda expressions.
This is mainly useful to mix imperative and declarative style when building sorts, e.g.:
f.composite( c -> { c.add( f.field( "category" ) ); if ( someInput != null ) { c.add( f.distance( "location", someInput.getLatitude(), someInput.getLongitude() ); } c.add( f.indexOrder() ); } )
- Specified by:
composite
in interfaceSearchSortFactory
- Parameters:
elementContributor
- A consumer that will add clauses to the step passed in parameter. Should generally be a lambda expression.- Returns:
- A DSL step where the "composite" sort can be defined in more details.
-
extension
public <T> T extension(SearchSortFactoryExtension<T> extension)
Description copied from interface:SearchSortFactory
Extend the current factory with the given extension, resulting in an extended factory offering different types of sorts.- Specified by:
extension
in interfaceSearchSortFactory
- Type Parameters:
T
- The type of factory provided by the extension.- Parameters:
extension
- The extension to the sort DSL.- Returns:
- The extended factory.
-
extension
public SearchSortFactoryExtensionIfSupportedStep extension()
Description copied from interface:SearchSortFactory
Create a DSL step allowing multiple attempts to apply extensions one after the other, failing only if none of the extensions is supported.If you only need to apply a single extension and fail if it is not supported, use the simpler
SearchSortFactory.extension(SearchSortFactoryExtension)
method instead.- Specified by:
extension
in interfaceSearchSortFactory
- Returns:
- A DSL step.
-
delegate
protected SearchSortFactory delegate()
-
-