public abstract class AbstractSearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,SF>,H,PDF extends SearchPredicateFactory,SF extends SearchSortFactory,C> extends Object implements SearchQueryPredicateStep<S,H,PDF>, SearchQueryOptionsStep<S,H,SF>
| Constructor and Description |
|---|
AbstractSearchQueryOptionsStep(IndexScope<C> indexScope,
SearchQueryBuilder<H,C> searchQueryBuilder) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract PDF |
extendPredicateFactory(SearchPredicateFactory predicateFactory) |
protected abstract SF |
extendSortFactory(SearchSortFactory sortFactory) |
SearchResult<H> |
fetch()
Execute the query and return the
SearchResult. |
SearchResult<H> |
fetch(Integer limit)
Execute the query and return the
SearchResult. |
SearchResult<H> |
fetch(Integer limit,
Integer offset)
Execute the query and return the
SearchResult. |
List<H> |
fetchHits()
Execute the query and return the hits as a
List. |
List<H> |
fetchHits(Integer limit)
Execute the query and return the hits as a
List. |
List<H> |
fetchHits(Integer limit,
Integer offset)
Execute the query and return the hits as a
List. |
Optional<H> |
fetchSingleHit()
Execute the query and return the hits as a single, optional element.
|
long |
fetchTotalHitCount()
Execute the query and return the total hit count.
|
S |
predicate(Function<? super PDF,? extends PredicateFinalStep> predicateContributor)
Set the predicate for this query.
|
S |
predicate(SearchPredicate predicate)
Set the predicate for this query.
|
S |
routing(Collection<String> routingKeys)
Configure routing of the search query.
|
S |
routing(String routingKey)
Configure routing of the search query.
|
S |
sort(Function<? super SF,? extends SortFinalStep> sortContributor)
Add a sort to this query.
|
S |
sort(SearchSort sort)
Add a sort to this query.
|
protected abstract S |
thisAsS() |
SearchQuery<H> |
toQuery()
Create a
SearchQuery instance
matching the definition given in the previous DSL steps. |
public AbstractSearchQueryOptionsStep(IndexScope<C> indexScope, SearchQueryBuilder<H,C> searchQueryBuilder)
public S predicate(SearchPredicate predicate)
SearchQueryPredicateSteppredicate in interface SearchQueryPredicateStep<S extends SearchQueryOptionsStep<S,H,SF>,H,PDF extends SearchPredicateFactory>predicate - A SearchPredicate object obtained from the search scope.public S predicate(Function<? super PDF,? extends PredicateFinalStep> predicateContributor)
SearchQueryPredicateSteppredicate in interface SearchQueryPredicateStep<S extends SearchQueryOptionsStep<S,H,SF>,H,PDF extends SearchPredicateFactory>predicateContributor - A function that will use the factory passed in parameter to create a predicate,
returning the final step in the predicate DSL.
Should generally be a lambda expression.public S routing(String routingKey)
SearchQueryOptionsStepUseful when indexes are sharded, to limit the number of shards interrogated by the search query.
This method may be called multiple times, in which case all submitted routing keys will be taken into account.
By default, if routing is not configured, all shards will be queried.
routing in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,SF>,H,SF extends SearchSortFactory>routingKey - A string key. All shards matching this key will be queried.this, for method chaining.public S routing(Collection<String> routingKeys)
SearchQueryOptionsStep
Similar to SearchQueryOptionsStep.routing(String), but allows passing multiple keys in a single call.
routing in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,SF>,H,SF extends SearchSortFactory>routingKeys - A collection containing zero, one or multiple string keys.this, for method chaining.public S sort(SearchSort sort)
SearchQueryOptionsStepsort in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,SF>,H,SF extends SearchSortFactory>sort - A SearchSort object obtained from the search scope.this, for method chaining.public S sort(Function<? super SF,? extends SortFinalStep> sortContributor)
SearchQueryOptionsStepsort in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,SF>,H,SF extends SearchSortFactory>sortContributor - A function that will use the factory passed in parameter to create a sort,
returning the final step in the sort DSL.
Should generally be a lambda expression.this, for method chaining.public SearchQuery<H> toQuery()
SearchQueryFinalStepSearchQuery instance
matching the definition given in the previous DSL steps.
Calling this method is generally not necessary as most query execution methods
are also implemented by this DSL step,
so for example .toQuery().fetch() can be replaced with simply .fetch().
toQuery in interface SearchQueryFinalStep<H>SearchQuery resulting from the previous DSL steps.public SearchResult<H> fetch()
SearchFetchableSearchResult.fetch in interface SearchFetchable<H>SearchResult.public SearchResult<H> fetch(Integer limit)
SearchFetchableSearchResult.fetch in interface SearchFetchable<H>limit - The maximum number of hits to be included in the SearchResult. null means no limit.SearchResult.public SearchResult<H> fetch(Integer limit, Integer offset)
SearchFetchableSearchResult.fetch in interface SearchFetchable<H>limit - The maximum number of hits to be included in the SearchResult. null means no limit.offset - The number of hits to skip before adding the hits to the SearchResult. null means no offset.SearchResult.public List<H> fetchHits()
SearchFetchableList.fetchHits in interface SearchFetchable<H>public List<H> fetchHits(Integer limit)
SearchFetchableList.fetchHits in interface SearchFetchable<H>limit - The maximum number of hits to be returned by this method. null means no limit.public List<H> fetchHits(Integer limit, Integer offset)
SearchFetchableList.fetchHits in interface SearchFetchable<H>limit - The maximum number of hits to be returned by this method. null means no limit.offset - The number of hits to skip. null means no offset.public Optional<H> fetchSingleHit()
SearchFetchablefetchSingleHit in interface SearchFetchable<H>public long fetchTotalHitCount()
SearchFetchablefetchTotalHitCount in interface SearchFetchable<H>protected abstract S thisAsS()
protected abstract PDF extendPredicateFactory(SearchPredicateFactory predicateFactory)
protected abstract SF extendSortFactory(SearchSortFactory sortFactory)
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.