public abstract class AbstractSearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,H,LOS,PDF extends SearchPredicateFactory,SF extends SearchSortFactory,AF extends SearchAggregationFactory,C> extends Object implements SearchQueryPredicateStep<S,H,PDF>, SearchQueryOptionsStep<S,H,LOS,SF,AF>
| Constructor and Description |
|---|
AbstractSearchQueryOptionsStep(IndexScope<C> indexScope,
SearchQueryBuilder<H,C> searchQueryBuilder,
LoadingContextBuilder<?,?,LOS> loadingContextBuilder) |
| Modifier and Type | Method and Description |
|---|---|
<A> S |
aggregation(AggregationKey<A> key,
Function<? super AF,? extends AggregationFinalStep<A>> aggregationContributor)
Add an aggregation to this query.
|
<A> S |
aggregation(AggregationKey<A> key,
SearchAggregation<A> aggregation)
Add an aggregation to this query.
|
protected abstract AF |
extendAggregationFactory(SearchAggregationFactory aggregationFactory) |
protected abstract PDF |
extendPredicateFactory(SearchPredicateFactory predicateFactory) |
protected abstract SF |
extendSortFactory(SearchSortFactory sortFactory) |
S |
failAfter(long timeout,
TimeUnit timeUnit)
Stop the query and throw a
SearchTimeoutException after a given timeout. |
SearchResult<H> |
fetch(Integer limit)
Execute the query and return the
SearchResult,
limiting to limit hits. |
SearchResult<H> |
fetch(Integer offset,
Integer limit)
|
SearchResult<H> |
fetchAll()
Execute the query and return the
SearchResult,
including all hits, without any sort of limit. |
List<H> |
fetchAllHits()
Execute the query and return all hits as a
List,
without any sort of limit. |
List<H> |
fetchHits(Integer limit)
Execute the query and return the hits as a
List,
limiting to limit hits. |
List<H> |
fetchHits(Integer offset,
Integer limit)
|
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 |
loading(Consumer<? super LOS> loadingOptionsContributor)
Configure entity loading for this query.
|
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. |
S |
truncateAfter(long timeout,
TimeUnit timeUnit)
Stop the query and return truncated results after a given timeout.
|
public AbstractSearchQueryOptionsStep(IndexScope<C> indexScope, SearchQueryBuilder<H,C> searchQueryBuilder, LoadingContextBuilder<?,?,LOS> loadingContextBuilder)
public S predicate(SearchPredicate predicate)
SearchQueryPredicateSteppredicate in interface SearchQueryPredicateStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,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,LOS,SF,AF>,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,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>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,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>routingKeys - A collection containing zero, one or multiple string keys.this, for method chaining.public S truncateAfter(long timeout, TimeUnit timeUnit)
SearchQueryOptionsStepThe timeout is handled on a best effort basis: Hibernate Search will *try* to stop the query as soon as possible after the timeout.
truncateAfter in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>timeout - Timeout value.timeUnit - Timeout unit.this, for method chaining.public S failAfter(long timeout, TimeUnit timeUnit)
SearchQueryOptionsStepSearchTimeoutException after a given timeout.
The timeout is handled on a best effort basis:
Hibernate Search will *try* to stop the query as soon as possible after the timeout.
However, this method is more likely to trigger an early stop than SearchQueryOptionsStep.truncateAfter(long, TimeUnit).
failAfter in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>timeout - Timeout value.timeUnit - Timeout unit.this, for method chaining.public S loading(Consumer<? super LOS> loadingOptionsContributor)
SearchQueryOptionsSteploading in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>loadingOptionsContributor - A consumer that will alter the loading options passed in parameter.
Should generally be a lambda expression.this, for method chaining.public S sort(SearchSort sort)
SearchQueryOptionsStepsort in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>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,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>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 <A> S aggregation(AggregationKey<A> key, SearchAggregation<A> aggregation)
SearchQueryOptionsStepaggregation in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>A - The type of aggregation values.key - The key that will be used to retrieve the aggregation
from the SearchResult.aggregation - A SearchAggregation object obtained from the search scope.this, for method chaining.public <A> S aggregation(AggregationKey<A> key, Function<? super AF,? extends AggregationFinalStep<A>> aggregationContributor)
SearchQueryOptionsStepaggregation in interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<S,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>A - The type of aggregation values.key - The key that will be used to retrieve the aggregation
from the SearchResult.aggregationContributor - A function that will use the factory passed in parameter to create an aggregation,
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> fetchAll()
SearchFetchableSearchResult,
including all hits, without any sort of limit.
SearchFetchable.fetch(Integer) or SearchFetchable.fetch(Integer, Integer) should generally be preferred, for performance reasons.
fetchAll in interface SearchFetchable<H>SearchResult.public SearchResult<H> fetch(Integer limit)
SearchFetchableSearchResult,
limiting to limit hits.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 offset, Integer limit)
SearchFetchablefetch in interface SearchFetchable<H>offset - The number of hits to skip before adding the hits to the SearchResult. null means no offset.limit - The maximum number of hits to be included in the SearchResult. null means no limit.SearchResult.public List<H> fetchAllHits()
SearchFetchableList,
without any sort of limit.
SearchFetchable.fetchHits(Integer) or SearchFetchable.fetchHits(Integer, Integer) should generally be preferred,
for performance reasons.
fetchAllHits in interface SearchFetchable<H>public List<H> fetchHits(Integer limit)
SearchFetchableList,
limiting to limit hits.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 offset, Integer limit)
SearchFetchablefetchHits in interface SearchFetchable<H>offset - The number of hits to skip. null means no offset.limit - The maximum number of hits to be returned by this method. null means no limit.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)
protected abstract AF extendAggregationFactory(SearchAggregationFactory aggregationFactory)
Copyright © 2006-2020 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.