public class DelegatingSearchSortFactoryContext extends Object implements SearchSortFactoryContext
SearchSortFactoryContext.
Mainly useful when implementing a SearchSortFactoryContextExtension.
| Constructor and Description |
|---|
DelegatingSearchSortFactoryContext(SearchSortFactoryContext delegate) |
| 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.
|
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.
|
protected SearchSortFactoryContext |
getDelegate() |
public DelegatingSearchSortFactoryContext(SearchSortFactoryContext delegate)
public ScoreSortContext byScore()
SearchSortFactoryContextThe default order is descending, i.e. higher scores come first.
byScore in interface SearchSortFactoryContextchain other sorts
or get the resulting sort.public NonEmptySortContext byIndexOrder()
SearchSortFactoryContextbyIndexOrder in interface SearchSortFactoryContextchain other sorts
or get the resulting sort.public FieldSortContext byField(String absoluteFieldPath)
SearchSortFactoryContextThe default order is ascending.
byField in interface SearchSortFactoryContextabsoluteFieldPath - The absolute path of the index field to sort bychain other sorts
or get the resulting sort.public DistanceSortContext byDistance(String absoluteFieldPath, GeoPoint location)
SearchSortFactoryContextThe default order is ascending.
byDistance in interface SearchSortFactoryContextabsoluteFieldPath - 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.public DistanceSortContext byDistance(String absoluteFieldPath, double latitude, double longitude)
SearchSortFactoryContextThe default order is ascending.
byDistance in interface SearchSortFactoryContextabsoluteFieldPath - 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.public CompositeSortContext byComposite()
SearchSortFactoryContext
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 SearchSortFactoryContext.byComposite(Consumer)
byComposite in interface SearchSortFactoryContextchain other sorts
or get the resulting sort.public NonEmptySortContext byComposite(Consumer<? super CompositeSortContext> elementContributor)
SearchSortFactoryContextBest 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() );
} )
byComposite in interface SearchSortFactoryContextelementContributor - 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.public <T> T extension(SearchSortFactoryContextExtension<T> extension)
SearchSortFactoryContextextension in interface SearchSortFactoryContextT - The type of context provided by the extension.extension - The extension to the sort DSL.public SearchSortFactoryExtensionContext extension()
SearchSortFactoryContext
If you only need to apply a single extension and fail if it is not supported,
use the simpler SearchSortFactoryContext.extension(SearchSortFactoryContextExtension) method instead.
extension in interface SearchSortFactoryContextprotected SearchSortFactoryContext getDelegate()
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.