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
Fields Modifier and Type Field Description protected SearchSortDslContext<SC,PDF>dslContext
-
Constructor Summary
Constructors Constructor Description AbstractSearchSortFactory(SearchSortDslContext<SC,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.SortThenStepcomposite(Consumer<? super CompositeSortComponentsStep<?>> elementContributor)Order by a sort composed of several elements, which will be defined by the given consumer.DistanceSortOptionsStep<?,PDF>distance(String fieldPath, GeoPoint location)Order elements by the distance from the location stored in the specified field to the location specified.SearchSortFactoryExtensionIfSupportedStepextension()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.FieldSortOptionsStep<?,PDF>field(String fieldPath)Order elements by the value of a specific field.SortThenStepindexOrder()Order elements by their internal index order.ScoreSortOptionsStep<?>score()Order elements by their relevance score.protected SortThenStepstaticThenStep(SearchSort sort)StringtoAbsolutePath(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 Detail
-
dslContext
protected final SearchSortDslContext<SC extends SearchSortIndexScope<?>,PDF extends SearchPredicateFactory> dslContext
-
-
Constructor Detail
-
AbstractSearchSortFactory
public AbstractSearchSortFactory(SearchSortDslContext<SC,PDF> dslContext)
-
-
Method Detail
-
score
public ScoreSortOptionsStep<?> score()
Description copied from interface:SearchSortFactoryOrder elements by their relevance score.The default order is descending, i.e. higher scores come first.
- Specified by:
scorein interfaceSearchSortFactory- Returns:
- A DSL step where the "score" sort can be defined in more details.
-
indexOrder
public SortThenStep indexOrder()
Description copied from interface:SearchSortFactoryOrder elements by their internal index order.- Specified by:
indexOrderin interfaceSearchSortFactory- Returns:
- A DSL step where the "index order" sort can be defined in more details.
-
field
public FieldSortOptionsStep<?,PDF> field(String fieldPath)
Description copied from interface:SearchSortFactoryOrder elements by the value of a specific field.The default order is ascending.
- Specified by:
fieldin interfaceExtendedSearchSortFactory<S extends ExtendedSearchSortFactory<S,PDF>,SC extends SearchSortIndexScope<?>>- Specified by:
fieldin 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
public DistanceSortOptionsStep<?,PDF> distance(String fieldPath, GeoPoint location)
Description copied from interface:SearchSortFactoryOrder 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<S extends ExtendedSearchSortFactory<S,PDF>,SC extends SearchSortIndexScope<?>>- Specified by:
distancein 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
public CompositeSortComponentsStep<?> composite()
Description copied from interface:SearchSortFactoryOrder 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:
compositein 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:SearchSortFactoryOrder 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- 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: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
public SearchSortFactoryExtensionIfSupportedStep extension()
Description copied from interface:SearchSortFactoryCreate 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- Returns:
- A DSL step.
-
toAbsolutePath
public final String toAbsolutePath(String relativeFieldPath)
- 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
protected final SortThenStep staticThenStep(SearchSort sort)
-
-