public interface SearchSortFactoryContext
| Modifier and Type | Method and Description |
|---|---|
CompositeSortContext |
byComposite()
Order by a sort composed of several elements.
|
NonEmptySortContext |
byComposite(Consumer<? super CompositeSortContext> elementContributor)
Order by a sort composed of several elements,
which will be defined by the given consumer.
|
default DistanceSortContext |
byDistance(String absoluteFieldPath,
double latitude,
double longitude)
Order elements by the distance from the location stored in the specified field to the location specified.
|
DistanceSortContext |
byDistance(String absoluteFieldPath,
GeoPoint location)
Order elements by the distance from the location stored in the specified field to the location specified.
|
FieldSortContext |
byField(String absoluteFieldPath)
Order elements by the value of a specific field.
|
NonEmptySortContext |
byIndexOrder()
Order elements by their internal index order.
|
ScoreSortContext |
byScore()
Order elements by their relevance score.
|
SearchSortFactoryExtensionContext |
extension()
Create a context allowing to try to apply multiple extensions one after the other,
failing only if none of the extensions is supported.
|
<T> T |
extension(SearchSortFactoryContextExtension<T> extension)
Extend the current context with the given extension,
resulting in an extended context offering different types of sorts.
|
ScoreSortContext byScore()
The default order is descending, i.e. higher scores come first.
chain other sorts
or get the resulting sort.NonEmptySortContext byIndexOrder()
chain other sorts
or get the resulting sort.FieldSortContext byField(String absoluteFieldPath)
The default order is ascending.
absoluteFieldPath - The absolute path of the index field to sort bychain other sorts
or get the resulting sort.SearchException - If the sort field type could not be automatically determined.DistanceSortContext byDistance(String absoluteFieldPath, GeoPoint location)
The default order is ascending.
absoluteFieldPath - The absolute path of the indexed location field to sort by.location - The location to which we want to compute the distance.chain other sorts
or get the resulting sort.SearchException - If the field type does not constitute a valid location.default DistanceSortContext byDistance(String absoluteFieldPath, double latitude, double longitude)
The default order is ascending.
absoluteFieldPath - The absolute path of the indexed location field to sort by.latitude - The latitude of the location to which we want to compute the distance.longitude - The longitude of the location to which we want to compute the distance.chain other sorts
or get the resulting sort.SearchException - If the field type does not constitute a valid location.CompositeSortContext byComposite()
Note that, in general, calling this method is not necessary as you can chain sorts by calling
NonEmptySortContext.then().
This method is mainly useful to mix imperative and declarative style when building sorts.
See byComposite(Consumer)
chain other sorts
or get the resulting sort.NonEmptySortContext byComposite(Consumer<? super CompositeSortContext> elementContributor)
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.byField( "category" ) );
if ( someInput != null ) {
c.add( f.byDistance( "location", someInput.getLatitude(), someInput.getLongitude() );
}
c.add( f.byIndexOrder() );
} )
elementContributor - A consumer that will add elements to the context passed in parameter.
Should generally be a lambda expression.chain other sorts
or get the resulting sort.<T> T extension(SearchSortFactoryContextExtension<T> extension)
T - The type of context provided by the extension.extension - The extension to the sort DSL.SearchException - If the extension cannot be applied (wrong underlying backend, ...).SearchSortFactoryExtensionContext extension()
If you only need to apply a single extension and fail if it is not supported,
use the simpler extension(SearchSortFactoryContextExtension) method instead.
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.