public abstract class AbstractSearchQueryContext<S extends SearchQueryContext<S,H,SC>,H,PDC extends SearchPredicateFactoryContext,SC extends SearchSortFactoryContext,C> extends Object implements SearchQueryResultContext<S,H,PDC>, SearchQueryContext<S,H,SC>
| Constructor and Description |
|---|
AbstractSearchQueryContext(IndexScope<C> indexScope,
SearchQueryBuilder<H,C> searchQueryBuilder) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract PDC |
extendPredicateContext(SearchPredicateFactoryContext predicateFactoryContext) |
protected abstract SC |
extendSortContext(SearchSortFactoryContext sortFactoryContext) |
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 PDC,? extends SearchPredicateTerminalContext> 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 SC,? extends SearchSortTerminalContext> sortContributor)
Add a sort to this query.
|
S |
sort(SearchSort sort)
Add a sort to this query.
|
protected abstract S |
thisAsS() |
SearchQuery<H> |
toQuery() |
public AbstractSearchQueryContext(IndexScope<C> indexScope, SearchQueryBuilder<H,C> searchQueryBuilder)
public S predicate(SearchPredicate predicate)
SearchQueryResultContextpredicate in interface SearchQueryResultContext<S extends SearchQueryContext<S,H,SC>,H,PDC extends SearchPredicateFactoryContext>predicate - A SearchPredicate object obtained from the search scope.public S predicate(Function<? super PDC,? extends SearchPredicateTerminalContext> predicateContributor)
SearchQueryResultContextpredicate in interface SearchQueryResultContext<S extends SearchQueryContext<S,H,SC>,H,PDC extends SearchPredicateFactoryContext>predicateContributor - A function that will use the DSL context passed in parameter to create a predicate,
returning the resulting terminal context.
Should generally be a lambda expression.public S routing(String routingKey)
SearchQueryContextUseful 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 SearchQueryContext<S extends SearchQueryContext<S,H,SC>,H,SC extends SearchSortFactoryContext>routingKey - A string key. All shards matching this key will be queried.this, for method chaining.public S routing(Collection<String> routingKeys)
SearchQueryContext
Similar to SearchQueryContext.routing(String), but allows passing multiple keys in a single call.
routing in interface SearchQueryContext<S extends SearchQueryContext<S,H,SC>,H,SC extends SearchSortFactoryContext>routingKeys - A collection containing zero, one or multiple string keys.this, for method chaining.public S sort(SearchSort sort)
SearchQueryContextsort in interface SearchQueryContext<S extends SearchQueryContext<S,H,SC>,H,SC extends SearchSortFactoryContext>sort - A SearchSort object obtained from the search scope.this, for method chaining.public S sort(Function<? super SC,? extends SearchSortTerminalContext> sortContributor)
SearchQueryContextsort in interface SearchQueryContext<S extends SearchQueryContext<S,H,SC>,H,SC extends SearchSortFactoryContext>sortContributor - A function that will use the DSL context passed in parameter to create a sort,
returning the resulting terminal context.
Should generally be a lambda expression.this, for method chaining.public SearchQuery<H> toQuery()
toQuery in interface SearchQueryContext<S extends SearchQueryContext<S,H,SC>,H,SC extends SearchSortFactoryContext>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 PDC extendPredicateContext(SearchPredicateFactoryContext predicateFactoryContext)
protected abstract SC extendSortContext(SearchSortFactoryContext sortFactoryContext)
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.