public class DelegatingSearchSortFactory extends Object implements SearchSortFactory
SearchSortFactory.
Mainly useful when implementing a SearchSortFactoryExtension.
| Constructor and Description |
|---|
DelegatingSearchSortFactory(SearchSortFactory delegate) |
| Modifier and Type | Method and Description |
|---|---|
CompositeSortComponentsStep |
byComposite()
Order by a sort composed of several elements.
|
SortThenStep |
byComposite(Consumer<? super CompositeSortComponentsStep> elementContributor)
Order by a sort composed of several elements,
which will be defined by the given consumer.
|
DistanceSortOptionsStep |
byDistance(String absoluteFieldPath,
double latitude,
double longitude)
Order elements by the distance from the location stored in the specified field to the location specified.
|
DistanceSortOptionsStep |
byDistance(String absoluteFieldPath,
GeoPoint location)
Order elements by the distance from the location stored in the specified field to the location specified.
|
FieldSortOptionsStep |
byField(String absoluteFieldPath)
Order elements by the value of a specific field.
|
SortThenStep |
byIndexOrder()
Order elements by their internal index order.
|
ScoreSortOptionsStep |
byScore()
Order elements by their relevance score.
|
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.
|
protected SearchSortFactory |
getDelegate() |
public DelegatingSearchSortFactory(SearchSortFactory delegate)
public ScoreSortOptionsStep byScore()
SearchSortFactoryThe default order is descending, i.e. higher scores come first.
byScore in interface SearchSortFactorypublic SortThenStep byIndexOrder()
SearchSortFactorybyIndexOrder in interface SearchSortFactorypublic FieldSortOptionsStep byField(String absoluteFieldPath)
SearchSortFactoryThe default order is ascending.
byField in interface SearchSortFactoryabsoluteFieldPath - The absolute path of the index field to sort bypublic DistanceSortOptionsStep byDistance(String absoluteFieldPath, GeoPoint location)
SearchSortFactoryThe default order is ascending.
byDistance in interface SearchSortFactoryabsoluteFieldPath - The absolute path of the indexed location field to sort by.location - The location to which we want to compute the distance.public DistanceSortOptionsStep byDistance(String absoluteFieldPath, double latitude, double longitude)
SearchSortFactoryThe default order is ascending.
byDistance in interface SearchSortFactoryabsoluteFieldPath - 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.public CompositeSortComponentsStep byComposite()
SearchSortFactory
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 SearchSortFactory.byComposite(Consumer)
byComposite in interface SearchSortFactorypublic SortThenStep byComposite(Consumer<? super CompositeSortComponentsStep> elementContributor)
SearchSortFactoryBest 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 SearchSortFactoryelementContributor - A consumer that will add clauses to the step passed in parameter.
Should generally be a lambda expression.public <T> T extension(SearchSortFactoryExtension<T> extension)
SearchSortFactoryextension in interface SearchSortFactoryT - The type of factory provided by the extension.extension - The extension to the sort DSL.public SearchSortFactoryExtensionIfSupportedStep extension()
SearchSortFactory
If you only need to apply a single extension and fail if it is not supported,
use the simpler SearchSortFactory.extension(SearchSortFactoryExtension) method instead.
extension in interface SearchSortFactoryprotected SearchSortFactory getDelegate()
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.