public interface SearchSortFactory
| Modifier and Type | Method and 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.
|
default DistanceSortOptionsStep<?> |
distance(String absoluteFieldPath,
double latitude,
double longitude)
Order elements by the distance from the location stored in the specified field to the location specified.
|
DistanceSortOptionsStep<?> |
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<?> |
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.
|
ScoreSortOptionsStep<?> score()
The default order is descending, i.e. higher scores come first.
SortThenStep indexOrder()
FieldSortOptionsStep<?> field(String absoluteFieldPath)
The default order is ascending.
absoluteFieldPath - The absolute path of the index field to sort bySearchException - If the field doesn't exist or cannot be sorted on.DistanceSortOptionsStep<?> distance(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.SearchException - If the field type does not constitute a valid location.default DistanceSortOptionsStep<?> distance(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.SearchException - If the field type does not constitute a valid location.CompositeSortComponentsStep<?> composite()
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.
See composite(Consumer)
SortThenStep composite(Consumer<? super CompositeSortComponentsStep<?>> 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 clauses to the step passed in parameter.
Should generally be a lambda expression.<T> T extension(SearchSortFactoryExtension<T> extension)
T - The type of factory provided by the extension.extension - The extension to the sort DSL.SearchException - If the extension cannot be applied (wrong underlying backend, ...).SearchSortFactoryExtensionIfSupportedStep extension()
If you only need to apply a single extension and fail if it is not supported,
use the simpler extension(SearchSortFactoryExtension) method instead.
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.