Class AbstractSearchSortFactory<SR,S extends ExtendedSearchSortFactory<SR,S,PDF>,SC extends SearchSortIndexScope<?>,PDF extends TypedSearchPredicateFactory<SR>>
- All Implemented Interfaces:
ExtendedSearchSortFactory<SR,,S, PDF> SearchSortFactory,TypedSearchSortFactory<SR>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOrder by a sort composed of several elements.composite(Consumer<? super CompositeSortOptionsCollector<?>> 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> Textension(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.<T> FieldSortOptionsGenericStep<SR, T, ?, ?, ? extends TypedSearchPredicateFactory<SR>> field(FieldSortFieldReference<? super SR, T> fieldReference) 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<SR> staticThenStep(SearchSort sort) final StringtoAbsolutePath(String relativeFieldPath) withParameters(Function<? super NamedValues, ? extends SortFinalStep> sortCreator) Delegating sort that creates the actual sort at query create time and provides access to query parameters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.search.engine.search.sort.dsl.ExtendedSearchSortFactory
distance, distance, distance, withRoot
-
Field Details
-
dslContext
protected final SearchSortDslContext<SR,SC extends SearchSortIndexScope<?>, dslContextPDF extends TypedSearchPredicateFactory<SR>>
-
-
Constructor Details
-
AbstractSearchSortFactory
-
-
Method Details
-
score
Description copied from interface:TypedSearchSortFactoryOrder elements by their relevance score.The default order is descending, i.e. higher scores come first.
- Specified by:
scorein interfaceSearchSortFactory- Specified by:
scorein interfaceTypedSearchSortFactory<SR>- Returns:
- A DSL step where the "score" sort can be defined in more details.
-
indexOrder
Description copied from interface:TypedSearchSortFactoryOrder elements by their internal index order.- Specified by:
indexOrderin interfaceSearchSortFactory- Specified by:
indexOrderin interfaceTypedSearchSortFactory<SR>- Returns:
- A DSL step where the "index order" sort can be defined in more details.
-
field
Description copied from interface:TypedSearchSortFactoryOrder elements by the value of a specific field.The default order is ascending.
- Specified by:
fieldin interfaceExtendedSearchSortFactory<SR,S extends ExtendedSearchSortFactory<SR, S, PDF>, SC extends SearchSortIndexScope<?>> - Specified by:
fieldin interfaceSearchSortFactory- Specified by:
fieldin interfaceTypedSearchSortFactory<SR>- 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.
-
field
public <T> FieldSortOptionsGenericStep<SR,T, field?, ?, ? extends TypedSearchPredicateFactory<SR>> (FieldSortFieldReference<? super SR, T> fieldReference) Description copied from interface:TypedSearchSortFactoryOrder elements by the value of a specific field.The default order is ascending.
- Specified by:
fieldin interfaceTypedSearchSortFactory<SR>- Parameters:
fieldReference- The field reference representing a definition of 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:TypedSearchSortFactoryOrder elements by the distance from the location stored in the specified field to the location specified.The default order is ascending.
- Specified by:
distancein interfaceExtendedSearchSortFactory<SR,S extends ExtendedSearchSortFactory<SR, S, PDF>, SC extends SearchSortIndexScope<?>> - Specified by:
distancein interfaceSearchSortFactory- Specified by:
distancein interfaceTypedSearchSortFactory<SR>- 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:TypedSearchSortFactoryOrder 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. SeeTypedSearchSortFactory.composite(Consumer)- Specified by:
compositein interfaceSearchSortFactory- Specified by:
compositein interfaceTypedSearchSortFactory<SR>- Returns:
- A DSL step where the "composite" sort can be defined in more details.
-
composite
public SortThenStep<SR> composite(Consumer<? super CompositeSortOptionsCollector<?>> elementContributor) Description copied from interface:TypedSearchSortFactoryOrder 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:
compositein interfaceSearchSortFactory- Specified by:
compositein interfaceTypedSearchSortFactory<SR>- 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.
-
withParameters
public SortThenStep<SR> withParameters(Function<? super NamedValues, ? extends SortFinalStep> sortCreator) Description copied from interface:TypedSearchSortFactoryDelegating sort that creates the actual sort at query create time and provides access to query parameters.Which sort exactly to create is defined by a function passed to the arguments of this sort.
- Specified by:
withParametersin interfaceSearchSortFactory- Specified by:
withParametersin interfaceTypedSearchSortFactory<SR>- Parameters:
sortCreator- The function defining an actual sort to apply.- Returns:
- A final DSL step in a parameterized sort definition.
-
extension
Description copied from interface:SearchSortFactoryExtend the current factory with the given extension, resulting in an extended factory offering different types of sorts.- Specified by:
extensionin 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:TypedSearchSortFactoryCreate 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:
extensionin interfaceSearchSortFactory- Specified by:
extensionin interfaceTypedSearchSortFactory<SR>- Returns:
- A DSL step.
-
toAbsolutePath
- Specified by:
toAbsolutePathin interfaceSearchSortFactory- Parameters:
relativeFieldPath- The path to a field, relative to therootof 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
-