public class DelegatingSearchSortFactory<PDF extends SearchPredicateFactory> extends Object implements ExtendedSearchSortFactory<PDF>
SearchSortFactory.
Mainly useful when implementing a SearchSortFactoryExtension.
| Constructor and Description |
|---|
DelegatingSearchSortFactory(SearchSortFactory delegate,
SearchSortDslContext<?,?,? extends PDF> dslContext) |
| 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.
|
DistanceSortOptionsStep<?,PDF> |
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<?,PDF> |
field(String absoluteFieldPath)
Order elements by the value of a specific field.
|
protected SearchSortFactory |
getDelegate() |
SortThenStep |
indexOrder()
Order elements by their internal index order.
|
ScoreSortOptionsStep<?> |
score()
Order elements by their relevance score.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdistancepublic DelegatingSearchSortFactory(SearchSortFactory delegate, SearchSortDslContext<?,?,? extends PDF> dslContext)
public ScoreSortOptionsStep<?> score()
SearchSortFactoryThe default order is descending, i.e. higher scores come first.
score in interface SearchSortFactorypublic SortThenStep indexOrder()
SearchSortFactoryindexOrder in interface SearchSortFactorypublic FieldSortOptionsStep<?,PDF> field(String absoluteFieldPath)
SearchSortFactoryThe default order is ascending.
field in interface ExtendedSearchSortFactory<PDF extends SearchPredicateFactory>field in interface SearchSortFactoryabsoluteFieldPath - The absolute path of the index field to sort bypublic DistanceSortOptionsStep<?,PDF> distance(String absoluteFieldPath, GeoPoint location)
SearchSortFactoryThe default order is ascending.
distance in interface ExtendedSearchSortFactory<PDF extends SearchPredicateFactory>distance 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 CompositeSortComponentsStep<?> composite()
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.composite(Consumer)
composite in interface SearchSortFactorypublic SortThenStep composite(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.field( "category" ) );
if ( someInput != null ) {
c.add( f.distance( "location", someInput.getLatitude(), someInput.getLongitude() );
}
c.add( f.indexOrder() );
} )
composite 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-2020 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.