Class BaseQuery
java.lang.Object
org.springframework.data.elasticsearch.core.query.BaseQuery
- All Implemented Interfaces:
Query
- Direct Known Subclasses:
CriteriaQuery
,NativeQuery
,SearchTemplateQuery
,StringQuery
BaseQuery
- Author:
- Rizwan Idrees, Mohsin Husen, Mark Paluch, Alen Turkovic, Sascha Woo, Farid Azaza, Peter-Josef Meisch, Peer Mueller, vdisk
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.elasticsearch.core.query.Query
Query.IdWithRouting, Query.PointInTime, Query.SearchType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HighlightQuery
protected Collection<String>
protected List<Query.IdWithRouting>
protected List<IndexBoost>
protected IndicesOptions
protected Integer
protected float
protected Pageable
protected Query.PointInTime
protected String
protected Boolean
protected List<RescorerQuery>
protected String
protected List<RuntimeField>
protected Duration
protected Query.SearchType
protected Sort
protected SourceFilter
protected Duration
protected boolean
protected Integer
Fields inherited from interface org.springframework.data.elasticsearch.core.query.Query
DEFAULT_PAGE, DEFAULT_PAGE_SIZE
-
Constructor Summary
Constructors -
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.void
addScriptedField
(ScriptedField scriptedField) final <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 requestboolean
Get fields to be returned as part of search requestgetIds()
Get indices optionsreturn the max of results.float
Get minimum scoreGet page settings if definedGet preferencereturns the number of documents that are requested when the reactive code does a batched search operation.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.boolean
boolean
used internally.void
setDocValueFields
(List<DocValueField> docValueFields) void
setExplain
(boolean explain) void
Set fields to be returned as part of search requestvoid
setHighlightQuery
(HighlightQuery highlightQuery) Sets theHighlightQuery
.void
setIds
(Collection<String> ids) Set Ids for a multi-get request run with this query.void
setIdsWithRouting
(List<Query.IdWithRouting> idsWithRouting) Set Ids with routing values for a multi-get request run with this query.void
setIndicesOptions
(IndicesOptions indicesOptions) void
setMaxResults
(Integer maxResults) void
setMinScore
(float minScore) final <T extends Query>
TsetPageable
(Pageable pageable) restrict result to entries on given page.void
setPointInTime
(Query.PointInTime pointInTime) void
setPreference
(String preference) Add preference filter to be added as part of search requestvoid
setQueryIsUpdatedByConverter
(boolean queryIsUpdatedByConverter) used internally.void
setReactiveBatchSize
(Integer reactiveBatchSize) void
setRequestCache
(Boolean value) sets the request_cache value for the query.void
setRescorerQueries
(List<RescorerQuery> rescorerQueryList) Sets theRescorerQuery
.void
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
setSearchType
(Query.SearchType searchType) void
void
setStoredFields
(List<String> storedFields) Set stored fields to be returned as part of search requestvoid
setTimeout
(Duration timeout) set the query timeoutvoid
setTrackScores
(boolean trackScores) Configures whether to track scores.void
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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.elasticsearch.core.query.Query
hasScrollTime
-
Field Details
-
sort
-
pageable
-
fields
-
storedFields
-
sourceFilter
-
minScore
protected float minScore -
ids
-
route
-
searchType
-
indicesOptions
-
trackScores
protected boolean trackScores -
preference
-
maxResults
-
highlightQuery
-
trackTotalHitsUpTo
-
scrollTime
-
timeout
-
searchAfter
-
indicesBoost
-
rescorerQueries
-
requestCache
-
idsWithRouting
-
runtimeFields
-
pointInTime
-
-
Constructor Details
-
BaseQuery
public BaseQuery() -
BaseQuery
-
-
Method Details
-
setSort
- Since:
- 5.1
-
getSort
-
getPageable
Description copied from interface:Query
Get page settings if defined- Specified by:
getPageable
in interfaceQuery
- Returns:
-
setPageable
Description copied from interface:Query
restrict result to entries on given page. Corresponds to the 'start' and 'rows' parameter in elasticsearch- Specified by:
setPageable
in interfaceQuery
- Returns:
-
addFields
Description copied from interface:Query
Add fields to be added as part of search request -
getFields
Description copied from interface:Query
Get fields to be returned as part of search request -
setFields
Description copied from interface:Query
Set fields to be returned as part of search request -
addStoredFields
Description copied from interface:Query
Add stored fields to be added as part of search request- Specified by:
addStoredFields
in interfaceQuery
-
getStoredFields
Description copied from interface:Query
Get stored fields to be returned as part of search request- Specified by:
getStoredFields
in interfaceQuery
- Returns:
- null if not set
-
setStoredFields
Description copied from interface:Query
Set stored fields to be returned as part of search request- Specified by:
setStoredFields
in interfaceQuery
-
addSourceFilter
Description copied from interface:Query
Add source filter to be added as part of search request- Specified by:
addSourceFilter
in interfaceQuery
-
getSourceFilter
Description copied from interface:Query
Get SourceFilter to be returned to get include and exclude source fields as part of search request.- Specified by:
getSourceFilter
in interfaceQuery
- Returns:
- SourceFilter
-
addSort
Description copied from interface:Query
AddSort
to query -
getMinScore
public float getMinScore()Description copied from interface:Query
Get minimum score- Specified by:
getMinScore
in interfaceQuery
- Returns:
-
setMinScore
public void setMinScore(float minScore) -
setIds
Set Ids for a multi-get request run with this query. Not used in any other searches.- Parameters:
ids
- list of id values
-
getIds
-
getIdsWithRouting
- Specified by:
getIdsWithRouting
in interfaceQuery
- Returns:
- Ids with routing values used in a multi-get request.
- See Also:
-
setIdsWithRouting
Set Ids with routing values for a multi-get request run with this query. Not used in any other searches.- Parameters:
idsWithRouting
- list of id values, must not be null- Since:
- 4.3
-
getRoute
Description copied from interface:Query
Get route -
setRoute
-
setSearchType
-
getSearchType
Description copied from interface:Query
Type of search- Specified by:
getSearchType
in interfaceQuery
- Returns:
-
getIndicesOptions
Description copied from interface:Query
Get indices options- Specified by:
getIndicesOptions
in interfaceQuery
- Returns:
- null if not set
-
setIndicesOptions
-
getTrackScores
public boolean getTrackScores()Description copied from interface:Query
Get if scores will be computed and tracked, regardless of whether sorting on a field. Defaults to false.- Specified by:
getTrackScores
in interfaceQuery
- Returns:
-
setTrackScores
public void setTrackScores(boolean trackScores) Configures whether to track scores.- Since:
- 3.1
-
getPreference
Description copied from interface:Query
Get preference- Specified by:
getPreference
in interfaceQuery
- Returns:
-
setPreference
Description copied from interface:Query
Add preference filter to be added as part of search request- Specified by:
setPreference
in interfaceQuery
-
isLimiting
public boolean isLimiting()- Specified by:
isLimiting
in interfaceQuery
- Returns:
- true if the query has a limit on the max number of results.
-
getMaxResults
Description copied from interface:Query
return the max of results. Must not return null whenQuery.isLimiting()
returns true.- Specified by:
getMaxResults
in interfaceQuery
-
setMaxResults
-
setHighlightQuery
Description copied from interface:Query
Sets theHighlightQuery
.- Specified by:
setHighlightQuery
in interfaceQuery
- Parameters:
highlightQuery
- the query to set
-
getHighlightQuery
- Specified by:
getHighlightQuery
in interfaceQuery
- Returns:
- the optional set
HighlightQuery
.
-
setTrackTotalHits
Description copied from interface:Query
Sets the flag whether to set the Track_total_hits parameter on queries- Specified by:
setTrackTotalHits
in interfaceQuery
- Parameters:
trackTotalHits
- the value to set.
-
getTrackTotalHits
Description copied from interface:Query
Sets the flag whether to set the Track_total_hits parameter on queries- Specified by:
getTrackTotalHits
in interfaceQuery
- Returns:
- the set value.
-
setTrackTotalHitsUpTo
Description copied from interface:Query
Sets the maximum value up to which total hits are tracked. Only relevant if #getTrackTotalHits is null- Specified by:
setTrackTotalHitsUpTo
in interfaceQuery
- Parameters:
trackTotalHitsUpTo
- max limit for trackTotalHits
-
getTrackTotalHitsUpTo
Description copied from interface:Query
Gets the maximum value up to which total hits are tracked. Only relevant if #getTrackTotalHits is null- Specified by:
getTrackTotalHitsUpTo
in interfaceQuery
- Returns:
- max limit for trackTotalHits
-
getScrollTime
Description copied from interface:Query
For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries. Must not return null whenQuery.hasScrollTime()
returns true.- Specified by:
getScrollTime
in interfaceQuery
- Returns:
- the scrolltime settings
-
setScrollTime
Description copied from interface:Query
For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.- Specified by:
setScrollTime
in interfaceQuery
- Parameters:
scrollTime
- the scrolltime settings
-
getTimeout
Description copied from interface:Query
Get the query timeout.- Specified by:
getTimeout
in interfaceQuery
- Returns:
- null if not set
-
setTimeout
set the query timeout- Since:
- 4.2
-
getExplain
public boolean getExplain()- Specified by:
getExplain
in interfaceQuery
- Returns:
- true when the query has the explain parameter set, defaults to false
-
setExplain
public void setExplain(boolean explain) - Parameters:
explain
- the explain flag on the query.
-
setSearchAfter
Description copied from interface:Query
Sets the setSearchAfter objects for this query.- Specified by:
setSearchAfter
in interfaceQuery
- Parameters:
searchAfter
- the setSearchAfter objects. These are obtained withSearchHit.getSortValues()
from a search result.
-
getSearchAfter
- Specified by:
getSearchAfter
in interfaceQuery
- Returns:
- the search_after objects.
-
addRescorerQuery
Description copied from interface:Query
Adds aRescorerQuery
.- Specified by:
addRescorerQuery
in interfaceQuery
- Parameters:
rescorerQuery
- the query to add to the list of rescorer queries, must not be null
-
setRescorerQueries
Description copied from interface:Query
Sets theRescorerQuery
.- Specified by:
setRescorerQueries
in interfaceQuery
- Parameters:
rescorerQueryList
- list of rescorer queries set, must not be null.
-
getRescorerQueries
Description copied from interface:Query
get the list ofRescorerQuery
s- Specified by:
getRescorerQueries
in interfaceQuery
-
setRequestCache
Description copied from interface:Query
sets the request_cache value for the query.- Specified by:
setRequestCache
in interfaceQuery
- Parameters:
value
- new value
-
getRequestCache
- Specified by:
getRequestCache
in interfaceQuery
- Returns:
- the request_cache value for this query.
-
addRuntimeField
Description copied from interface:Query
Adds a runtime field to the query.- Specified by:
addRuntimeField
in interfaceQuery
- Parameters:
runtimeField
- the runtime field definition, must not be null
-
getRuntimeFields
- Specified by:
getRuntimeFields
in interfaceQuery
- Returns:
- the runtime fields for this query. May be empty but not null
-
getIndicesBoost
- Specified by:
getIndicesBoost
in interfaceQuery
-
getPointInTime
- Specified by:
getPointInTime
in interfaceQuery
- Returns:
- the point in time id to use in the query
- Since:
- 5.0
-
setPointInTime
- Since:
- 5.0
-
queryIsUpdatedByConverter
public boolean queryIsUpdatedByConverter()used internally. Not considered part of the API.- Since:
- 5.0
-
setQueryIsUpdatedByConverter
public void setQueryIsUpdatedByConverter(boolean queryIsUpdatedByConverter) used internally. Not considered part of the API.- Since:
- 5.0
-
getReactiveBatchSize
Description copied from interface:Query
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.- Specified by:
getReactiveBatchSize
in interfaceQuery
- Returns:
- the batch size, defaults to 500 in
BaseQuery
-
setReactiveBatchSize
- Since:
- 5.1
-
getAllowNoIndices
- Specified by:
getAllowNoIndices
in interfaceQuery
-
getExpandWildcards
- Specified by:
getExpandWildcards
in interfaceQuery
-
getDocValueFields
- Specified by:
getDocValueFields
in interfaceQuery
- Returns:
- a possible empty list of docvalue_field values to be set on the query.
- Since:
- 5.1
-
setDocValueFields
- Since:
- 5.1
-
addScriptedField
- Since:
- 5.2
-
getScriptedFields
- Specified by:
getScriptedFields
in interfaceQuery
- Returns:
- the list of scripted fields for the query
-