Class AbstractSearchSortFactory<S extends ExtendedSearchSortFactory<S,PDF>,SC extends SearchSortIndexScope<?>,PDF extends SearchPredicateFactory>
java.lang.Object
org.hibernate.search.engine.search.sort.dsl.spi.AbstractSearchSortFactory<S,SC,PDF>
- All Implemented Interfaces:
ExtendedSearchSortFactory<S,
,PDF> SearchSortFactory
public abstract class AbstractSearchSortFactory<S extends ExtendedSearchSortFactory<S,PDF>,SC extends SearchSortIndexScope<?>,PDF extends SearchPredicateFactory>
extends Object
implements ExtendedSearchSortFactory<S,PDF>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionOrder by a sort composed of several elements.composite
(Consumer<? super CompositeSortComponentsStep<?>> elementContributor) Order by a sort composed of several elements, which will be defined by the given consumer.Order elements by the distance from the location stored in the specified field to the location specified.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.Order elements by the value of a specific field.Order elements by their internal index order.score()
Order elements by their relevance score.protected final SortThenStep
staticThenStep
(SearchSort sort) final String
toAbsolutePath
(String relativeFieldPath) 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, withRoot
-
Field Details
-
dslContext
protected final SearchSortDslContext<SC extends SearchSortIndexScope<?>,PDF extends SearchPredicateFactory> dslContext
-
-
Constructor Details
-
AbstractSearchSortFactory
-
-
Method Details
-
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
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
Description copied from interface:SearchSortFactory
Order elements by the value of a specific field.The default order is ascending.
- Specified by:
field
in interfaceExtendedSearchSortFactory<S extends ExtendedSearchSortFactory<S,
PDF>, SC extends SearchSortIndexScope<?>> - Specified by:
field
in interfaceSearchSortFactory
- Parameters:
fieldPath
- The path to the index field to sort by.- Returns:
- A DSL step where the "field" sort can be defined in more details.
-
distance
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<S extends ExtendedSearchSortFactory<S,
PDF>, SC extends SearchSortIndexScope<?>> - Specified by:
distance
in interfaceSearchSortFactory
- Parameters:
fieldPath
- The path to the index field containing the location to compute the distance from.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
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
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
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
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.
-
toAbsolutePath
- Specified by:
toAbsolutePath
in interfaceSearchSortFactory
- Parameters:
relativeFieldPath
- The path to a field, relative to theroot
of this factory.- Returns:
- The absolute path of the field, for use in native sorts for example. Note the path is returned even if the field doesn't exist.
-
staticThenStep
-