Interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<?,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory>
-
- Type Parameters:
S
- The "self" type (the actual exposed type of this step). May be a subtype of SearchQueryOptionsStep with more exposed methods.H
- The type of hits for the created query.LOS
- The type of the initial step of the loading options definition DSL accessible throughloading(Consumer)
.SF
- The type of factory used to create sorts insort(Function)
.AF
- The type of factory used to create aggregations inaggregation(AggregationKey, Function)
.
- All Superinterfaces:
SearchFetchable<H>
,SearchQueryFinalStep<H>
- All Known Subinterfaces:
ElasticsearchSearchQueryOptionsStep<H,LOS>
,LuceneSearchQueryOptionsStep<H,LOS>
- All Known Implementing Classes:
AbstractExtendedSearchQueryOptionsStep
,AbstractSearchQueryOptionsStep
public interface SearchQueryOptionsStep<S extends SearchQueryOptionsStep<?,H,LOS,SF,AF>,H,LOS,SF extends SearchSortFactory,AF extends SearchAggregationFactory> extends SearchQueryFinalStep<H>, SearchFetchable<H>
The final step in a query definition, where optional parameters such assorts
can be set, and where the query can beexecuted
orretrieved as an object
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> S
aggregation(AggregationKey<T> key, Function<? super AF,? extends AggregationFinalStep<T>> aggregationContributor)
Add an aggregation to this query.<T> S
aggregation(AggregationKey<T> key, SearchAggregation<T> aggregation)
Add an aggregation to this query.S
failAfter(long timeout, TimeUnit timeUnit)
Stop the query and throw aSearchTimeoutException
after a given timeout.S
loading(Consumer<? super LOS> loadingOptionsContributor)
Configure entity loading for this query.S
routing(String routingKey)
Configure routing of the search query.S
routing(Collection<String> routingKeys)
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.S
totalHitCountThreshold(long totalHitCountThreshold)
Allow Hibernate Search to return a lower-bound estimate of the total hit count if it exceedstotalHitCountThreshold
.S
truncateAfter(long timeout, TimeUnit timeUnit)
Stop the query and return truncated results after a given timeout.-
Methods inherited from interface org.hibernate.search.engine.search.query.SearchFetchable
fetch, fetch, fetchAll, fetchAllHits, fetchHits, fetchHits, fetchSingleHit, fetchTotalHitCount, scroll
-
Methods inherited from interface org.hibernate.search.engine.search.query.dsl.SearchQueryFinalStep
toQuery
-
-
-
-
Method Detail
-
routing
S routing(String routingKey)
Configure routing of the search query.Useful 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.
- Parameters:
routingKey
- A string key. All shards matching this key will be queried.- Returns:
this
, for method chaining.
-
routing
S routing(Collection<String> routingKeys)
Configure routing of the search query.Similar to
routing(String)
, but allows passing multiple keys in a single call.- Parameters:
routingKeys
- A collection containing zero, one or multiple string keys.- Returns:
this
, for method chaining.
-
truncateAfter
S truncateAfter(long timeout, TimeUnit timeUnit)
Stop the query and return truncated results 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.
- Parameters:
timeout
- Timeout value.timeUnit
- Timeout unit.- Returns:
this
, for method chaining.
-
failAfter
S failAfter(long timeout, TimeUnit timeUnit)
Stop the query and throw aSearchTimeoutException
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
truncateAfter(long, TimeUnit)
.- Parameters:
timeout
- Timeout value.timeUnit
- Timeout unit.- Returns:
this
, for method chaining.
-
loading
S loading(Consumer<? super LOS> loadingOptionsContributor)
Configure entity loading for this query.- Parameters:
loadingOptionsContributor
- A consumer that will alter the loading options passed in parameter. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
sort
S sort(SearchSort sort)
Add a sort to this query.- Parameters:
sort
- ASearchSort
object obtained from the search scope.- Returns:
this
, for method chaining.
-
sort
S sort(Function<? super SF,? extends SortFinalStep> sortContributor)
Add a sort to this query.- Parameters:
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.- Returns:
this
, for method chaining.
-
aggregation
<T> S aggregation(AggregationKey<T> key, SearchAggregation<T> aggregation)
Add an aggregation to this query.- Type Parameters:
T
- The type of aggregation values.- Parameters:
key
- The key that will be used toretrieve the aggregation
from theSearchResult
.aggregation
- ASearchAggregation
object obtained from the search scope.- Returns:
this
, for method chaining.
-
aggregation
<T> S aggregation(AggregationKey<T> key, Function<? super AF,? extends AggregationFinalStep<T>> aggregationContributor)
Add an aggregation to this query.- Type Parameters:
T
- The type of aggregation values.- Parameters:
key
- The key that will be used toretrieve the aggregation
from theSearchResult
.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.- Returns:
this
, for method chaining.
-
totalHitCountThreshold
S totalHitCountThreshold(long totalHitCountThreshold)
Allow Hibernate Search to return a lower-bound estimate of the total hit count if it exceedstotalHitCountThreshold
.Allowing Hibernate Search to return a lower-bound estimate of the total hit count can lead to significantly fewer index scans and yield significant performance improvements, in particular when sorting by score (the default) on a large result set.
Note this optimization has no effect when also requesting aggregations.
- Parameters:
totalHitCountThreshold
- the value below which the hit count is always exact- Returns:
this
, for method chaining.- See Also:
SearchResultTotal
-
-