Interface Query
- All Known Implementing Classes:
BaseQuery
,CriteriaQuery
,NativeQuery
,SearchTemplateQuery
,StringQuery
public interface Query
Query
- Author:
- Rizwan Idrees, Mohsin Husen, Mark Paluch, Alen Turkovic, Sascha Woo, Christoph Strobl, Farid Azaza, Peter-Josef Meisch, Peer Mueller, vdisk
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
Value class combining an id with a routing value.static final record
Desscribes the point in time parameters for a querystatic enum
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add fields to be added as part of search requestvoid
addRescorerQuery
(RescorerQuery rescorerQuery) Adds aRescorerQuery
.void
addRuntimeField
(RuntimeField runtimeField) Adds a runtime field to the query.<T extends Query>
TAddSort
to queryvoid
addSourceFilter
(SourceFilter sourceFilter) Add source filter to be added as part of search requestvoid
addStoredFields
(String... storedFields) Add stored fields to be added as part of search requeststatic Query
findAll()
Get aQuery
that matches all documents in the index.default boolean
Get fields to be returned as part of search requestdefault Optional<HighlightQuery>
getIds()
Get indices optionsdefault Integer
return the max of results.float
Get minimum scoreGet page settings if defineddefault Query.PointInTime
Get preferencedefault Integer
returns the number of documents that are requested when the reactive code does a batched search operation.default List<RescorerQuery>
get the list ofRescorerQuery
sgetRoute()
Get routeFor queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.Type of searchgetSort()
Get SourceFilter to be returned to get include and exclude source fields as part of search request.Get stored fields to be returned as part of search requestGet the query timeout.boolean
Get if scores will be computed and tracked, regardless of whether sorting on a field.Sets the flag whether to set the Track_total_hits parameter on queriesGets the maximum value up to which total hits are tracked.default boolean
default boolean
static Query
multiGetQuery
(Collection<String> ids) Utility method to get a query for a multiget requeststatic Query
multiGetQueryWithRouting
(List<Query.IdWithRouting> idsWithRouting) Utility method to get a query for a multiget requestvoid
Set fields to be returned as part of search requestvoid
setHighlightQuery
(HighlightQuery highlightQuery) Sets theHighlightQuery
.<T extends Query>
TsetPageable
(Pageable pageable) restrict result to entries on given page.void
setPreference
(String preference) Add preference filter to be added as part of search requestvoid
setRequestCache
(Boolean value) sets the request_cache value for the query.void
setRescorerQueries
(List<RescorerQuery> rescorerQueryList) Sets theRescorerQuery
.void
setScrollTime
(Duration scrollTime) For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.void
setSearchAfter
(List<Object> searchAfter) Sets the setSearchAfter objects for this query.void
setStoredFields
(List<String> storedFields) Set stored fields to be returned as part of search requestvoid
setTrackTotalHits
(Boolean trackTotalHits) Sets the flag whether to set the Track_total_hits parameter on queriesvoid
setTrackTotalHitsUpTo
(Integer trackTotalHitsUpTo) Sets the maximum value up to which total hits are tracked.
-
Field Details
-
DEFAULT_PAGE_SIZE
static final int DEFAULT_PAGE_SIZE- See Also:
-
DEFAULT_PAGE
-
-
Method Details
-
findAll
Get aQuery
that matches all documents in the index.- Returns:
- new instance of
Query
. - Since:
- 3.2
-
setPageable
restrict result to entries on given page. Corresponds to the 'start' and 'rows' parameter in elasticsearch- Parameters:
pageable
-- Returns:
-
getPageable
Pageable getPageable()Get page settings if defined- Returns:
-
addSort
AddSort
to query- Parameters:
sort
-- Returns:
-
getSort
- Returns:
- null if not set
-
addFields
Add fields to be added as part of search request- Parameters:
fields
-
-
getFields
Get fields to be returned as part of search request- Returns:
- maybe empty, never null
-
setFields
Set fields to be returned as part of search request- Parameters:
fields
- must not be null- Since:
- 4.3
-
addStoredFields
Add stored fields to be added as part of search request- Parameters:
storedFields
-- Since:
- 4.4
-
getStoredFields
Get stored fields to be returned as part of search request- Returns:
- null if not set
- Since:
- 4.4
-
setStoredFields
Set stored fields to be returned as part of search request- Parameters:
storedFields
-- Since:
- 4.4
-
addSourceFilter
Add source filter to be added as part of search request- Parameters:
sourceFilter
-
-
getSourceFilter
Get SourceFilter to be returned to get include and exclude source fields as part of search request.- Returns:
- SourceFilter
-
getMinScore
float getMinScore()Get minimum score- Returns:
-
getTrackScores
boolean getTrackScores()Get if scores will be computed and tracked, regardless of whether sorting on a field. Defaults to false.- Returns:
- Since:
- 3.1
-
getIds
- Returns:
- Get ids set on this query.
-
getIdsWithRouting
List<Query.IdWithRouting> getIdsWithRouting()- Returns:
- Ids with routing values used in a multi-get request.
- Since:
- 4.3
- See Also:
-
multiGetQueryWithRouting
Utility method to get a query for a multiget request- Parameters:
idsWithRouting
- Ids with routing values used in a multi-get request.- Returns:
- Query instance
-
multiGetQuery
Utility method to get a query for a multiget request- Parameters:
ids
- Ids used in a multi-get request.- Returns:
- Query instance
-
getRoute
Get route- Returns:
-
getSearchType
Type of search- Returns:
-
getIndicesOptions
Get indices options- Returns:
- null if not set
-
getPreference
Get preference- Returns:
- Since:
- 3.2
-
setPreference
Add preference filter to be added as part of search request- Parameters:
preference
-- Since:
- 3.2
-
isLimiting
default boolean isLimiting()- Returns:
- true if the query has a limit on the max number of results.
- Since:
- 4.0
-
getMaxResults
return the max of results. Must not return null whenisLimiting()
returns true.- Since:
- 4.0
-
setHighlightQuery
Sets theHighlightQuery
.- Parameters:
highlightQuery
- the query to set- Since:
- 4.0
-
getHighlightQuery
- Returns:
- the optional set
HighlightQuery
. - Since:
- 4.0
-
setTrackTotalHits
Sets the flag whether to set the Track_total_hits parameter on queries- Parameters:
trackTotalHits
- the value to set.- Since:
- 4.0
-
getTrackTotalHits
Sets the flag whether to set the Track_total_hits parameter on queries- Returns:
- the set value.
- Since:
- 4.0
-
setTrackTotalHitsUpTo
Sets the maximum value up to which total hits are tracked. Only relevant if #getTrackTotalHits is null- Parameters:
trackTotalHitsUpTo
- max limit for trackTotalHits- Since:
- 4.1
-
getTrackTotalHitsUpTo
Gets the maximum value up to which total hits are tracked. Only relevant if #getTrackTotalHits is null- Returns:
- max limit for trackTotalHits
- Since:
- 4.1
-
getScrollTime
For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries. Must not return null whenhasScrollTime()
returns true.- Returns:
- the scrolltime settings
- Since:
- 4.0
-
setScrollTime
For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.- Parameters:
scrollTime
- the scrolltime settings- Since:
- 4.0
-
hasScrollTime
default boolean hasScrollTime()- Returns:
- true if a scroll time is set.
- Since:
- 4.0
-
getTimeout
Get the query timeout.- Returns:
- null if not set
- Since:
- 4.2
-
getExplain
default boolean getExplain()- Returns:
- true when the query has the explain parameter set, defaults to false
- Since:
- 4.2
-
setSearchAfter
Sets the setSearchAfter objects for this query.- Parameters:
searchAfter
- the setSearchAfter objects. These are obtained withSearchHit.getSortValues()
from a search result.- Since:
- 4.2
-
getSearchAfter
- Returns:
- the search_after objects.
- Since:
- 4.2
-
addRescorerQuery
Adds aRescorerQuery
.- Parameters:
rescorerQuery
- the query to add to the list of rescorer queries, must not be null- Since:
- 4.2
-
setRescorerQueries
Sets theRescorerQuery
.- Parameters:
rescorerQueryList
- list of rescorer queries set, must not be null.- Since:
- 4.2
-
getRescorerQueries
get the list ofRescorerQuery
s- Since:
- 4.2
-
setRequestCache
sets the request_cache value for the query.- Parameters:
value
- new value- Since:
- 4.3
-
getRequestCache
- Returns:
- the request_cache value for this query.
- Since:
- 4.3
-
addRuntimeField
Adds a runtime field to the query.- Parameters:
runtimeField
- the runtime field definition, must not be null- Since:
- 4.3
-
getRuntimeFields
List<RuntimeField> getRuntimeFields()- Returns:
- the runtime fields for this query. May be empty but not null
- Since:
- 4.3
-
getIndicesBoost
- Since:
- 4.4
-
getPointInTime
- Returns:
- the point in time id to use in the query
- Since:
- 5.0
-
getReactiveBatchSize
returns the number of documents that are requested when the reactive code does a batched search operation. This is the case when a query has no limit and no Pageable set.- Returns:
- the batch size, defaults to 500 in
BaseQuery
- Since:
- 5.1
-
getAllowNoIndices
- Since:
- 5.1
-
getExpandWildcards
- Since:
- 5.1
-
getDocValueFields
List<DocValueField> getDocValueFields()- Returns:
- a possible empty list of docvalue_field values to be set on the query.
- Since:
- 5.1
-
getScriptedFields
List<ScriptedField> getScriptedFields()- Returns:
- the list of scripted fields for the query
- Since:
- 5.1
-