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
sorts
can be set,
and where the query can be executed
or retrieved as an object
.-
Method Summary
Modifier and TypeMethodDescription<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.Stop the query and throw aSearchTimeoutException
after a given timeout.highlighter
(String highlighterName, Function<? super SearchHighlighterFactory, ? extends HighlighterFinalStep> highlighterContributor) Configure a named highlighter.highlighter
(String highlighterName, SearchHighlighter highlighter) Configure a named highlighter.highlighter
(Function<? super SearchHighlighterFactory, ? extends HighlighterFinalStep> highlighterContributor) Configure the default highlighter.highlighter
(SearchHighlighter highlighter) Configure the default highlighter.Configure entity loading for this query.Add query parameter.Configure routing of the search query.routing
(Collection<String> routingKeys) Configure routing of the search query.sort
(Function<? super SF, ? extends SortFinalStep> sortContributor) Add a sort to this query.sort
(SearchSort sort) Add a sort to this query.totalHitCountThreshold
(long totalHitCountThreshold) Allow Hibernate Search to return a lower-bound estimate of the total hit count if it exceedstotalHitCountThreshold
.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 Details
-
routing
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
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
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
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
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
Add a sort to this query.- Parameters:
sort
- ASearchSort
object obtained from the search scope.- Returns:
this
, for method chaining.
-
sort
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
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
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:
-
highlighter
@Incubating S highlighter(Function<? super SearchHighlighterFactory, ? extends HighlighterFinalStep> highlighterContributor) Configure the default highlighter.For specifying the fields to highlight see
SearchProjectionFactory.highlight(String)
. For providing field-specific settings to override the ones set here seehighlighter(String, Function)
.Backend specific defaults will be used if no configuration is provided.
- Parameters:
highlighterContributor
- a function that will use a highlighter factory to configure the default highlighter for this query.- Returns:
this
, for method chaining.
-
highlighter
Configure the default highlighter.For specifying the fields to highlight see
SearchProjectionFactory.highlight(String)
. For providing field-specific settings to override the ones set here seehighlighter(String, Function)
.Backend specific defaults will be used if no configuration is provided.
- Parameters:
highlighter
- a highlighter obtained from the search scope to be used as the default highlighter for this query.- Returns:
this
, for method chaining.
-
highlighter
@Incubating S highlighter(String highlighterName, Function<? super SearchHighlighterFactory, ? extends HighlighterFinalStep> highlighterContributor) Configure a named highlighter.Named highlighters are to be referenced in
highlight projections
.Named highlighters override the settings set by a default highlighter if such was configured for this query.
The highlighter type must be the same as the default highlighter's, if a
default highlighter settings was configured
for this query.- Parameters:
highlighterName
- name of the highlighter. Can be referenced when defining ahighlight projection
.highlighterContributor
- a function that will use a highlighter factory to configure the named highlighter.- Returns:
this
, for method chaining.- See Also:
-
highlighter
Configure a named highlighter.Named highlighters are to be referenced in
highlight projections
.Named highlighters override the settings set by a default highlighter if such was configured for this query.
The highlighter type must be the same as the default highlighter's, if a
default highlighter settings was configured
for this query.- Parameters:
highlighterName
- name of the highlighter. Can be referenced when defining ahighlight projection
.highlighter
- a highlighter obtained from the search scope that will serve as the named highlighter.- Returns:
this
, for method chaining.- See Also:
-
param
Add query parameter.Query parameters are intended to use in various
withParameters(..)
to create projections/predicates/sorts/aggregations relying on these query parameters.- Parameters:
parameterName
- The name of a query parameter.value
- The value of a query parameter.- Returns:
this
, for method chaining.
-