Class BaseQuery
java.lang.Object
org.springframework.data.elasticsearch.core.query.BaseQuery
- All Implemented Interfaces:
Query
- Direct Known Subclasses:
CriteriaQuery,NativeQuery,NativeSearchQuery,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 HighlightQueryprotected Collection<String>protected List<Query.IdWithRouting>protected List<IndexBoost>protected IndicesOptionsprotected Integerprotected floatprotected Pageableprotected Query.PointInTimeprotected Stringprotected Booleanprotected List<RescorerQuery>protected Stringprotected List<RuntimeField>protected Durationprotected Query.SearchTypeprotected Sortprotected SourceFilterprotected Durationprotected booleanprotected IntegerFields inherited from interface org.springframework.data.elasticsearch.core.query.Query
DEFAULT_PAGE, DEFAULT_PAGE_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd fields to be added as part of search requestvoidaddRescorerQuery(RescorerQuery rescorerQuery) Adds aRescorerQuery.voidaddRuntimeField(RuntimeField runtimeField) Adds a runtime field to the query.final <T extends Query>
TAddSortto queryvoidaddSourceFilter(SourceFilter sourceFilter) Add source filter to be added as part of search requestvoidaddStoredFields(String... storedFields) Add stored fields to be added as part of search requestbooleanGet fields to be returned as part of search requestgetIds()Get indices optionsreturn the max of results.floatGet 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 ofRescorerQuerysgetRoute()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.booleanGet 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.booleanbooleanused internally.voidsetDocValueFields(List<DocValueField> docValueFields) voidsetExplain(boolean explain) voidSet fields to be returned as part of search requestvoidsetHighlightQuery(HighlightQuery highlightQuery) Sets theHighlightQuery.voidsetIds(Collection<String> ids) Set Ids for a multi-get request run with this query.voidsetIdsWithRouting(List<Query.IdWithRouting> idsWithRouting) Set Ids with routing values for a multi-get request run with this query.voidsetIndicesOptions(IndicesOptions indicesOptions) voidsetMaxResults(Integer maxResults) voidsetMinScore(float minScore) final <T extends Query>
TsetPageable(Pageable pageable) restrict result to entries on given page.voidsetPointInTime(Query.PointInTime pointInTime) voidsetPreference(String preference) Add preference filter to be added as part of search requestvoidsetQueryIsUpdatedByConverter(boolean queryIsUpdatedByConverter) used internally.voidsetReactiveBatchSize(Integer reactiveBatchSize) voidsetRequestCache(Boolean value) sets the request_cache value for the query.voidsetRescorerQueries(List<RescorerQuery> rescorerQueryList) Sets theRescorerQuery.voidvoidsetScrollTime(Duration scrollTime) For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.voidsetSearchAfter(List<Object> searchAfter) Sets the setSearchAfter objects for this query.voidsetSearchType(Query.SearchType searchType) voidvoidsetStoredFields(List<String> storedFields) Set stored fields to be returned as part of search requestvoidsetTimeout(Duration timeout) set the query timeoutvoidsetTrackScores(boolean trackScores) Configures whether to track scores.voidsetTrackTotalHits(Boolean trackTotalHits) Sets the flag whether to set the Track_total_hits parameter on queriesvoidsetTrackTotalHitsUpTo(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, waitMethods 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:QueryGet page settings if defined- Specified by:
getPageablein interfaceQuery- Returns:
-
setPageable
Description copied from interface:Queryrestrict result to entries on given page. Corresponds to the 'start' and 'rows' parameter in elasticsearch- Specified by:
setPageablein interfaceQuery- Returns:
-
addFields
Description copied from interface:QueryAdd fields to be added as part of search request -
getFields
Description copied from interface:QueryGet fields to be returned as part of search request -
setFields
Description copied from interface:QuerySet fields to be returned as part of search request -
addStoredFields
Description copied from interface:QueryAdd stored fields to be added as part of search request- Specified by:
addStoredFieldsin interfaceQuery
-
getStoredFields
Description copied from interface:QueryGet stored fields to be returned as part of search request- Specified by:
getStoredFieldsin interfaceQuery- Returns:
- null if not set
-
setStoredFields
Description copied from interface:QuerySet stored fields to be returned as part of search request- Specified by:
setStoredFieldsin interfaceQuery
-
addSourceFilter
Description copied from interface:QueryAdd source filter to be added as part of search request- Specified by:
addSourceFilterin interfaceQuery
-
getSourceFilter
Description copied from interface:QueryGet SourceFilter to be returned to get include and exclude source fields as part of search request.- Specified by:
getSourceFilterin interfaceQuery- Returns:
- SourceFilter
-
addSort
Description copied from interface:QueryAddSortto query -
getMinScore
public float getMinScore()Description copied from interface:QueryGet minimum score- Specified by:
getMinScorein 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:
getIdsWithRoutingin 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:QueryGet route -
setRoute
-
setSearchType
-
getSearchType
Description copied from interface:QueryType of search- Specified by:
getSearchTypein interfaceQuery- Returns:
-
getIndicesOptions
Description copied from interface:QueryGet indices options- Specified by:
getIndicesOptionsin interfaceQuery- Returns:
- null if not set
-
setIndicesOptions
-
getTrackScores
public boolean getTrackScores()Description copied from interface:QueryGet if scores will be computed and tracked, regardless of whether sorting on a field. Defaults to false.- Specified by:
getTrackScoresin interfaceQuery- Returns:
-
setTrackScores
public void setTrackScores(boolean trackScores) Configures whether to track scores.- Since:
- 3.1
-
getPreference
Description copied from interface:QueryGet preference- Specified by:
getPreferencein interfaceQuery- Returns:
-
setPreference
Description copied from interface:QueryAdd preference filter to be added as part of search request- Specified by:
setPreferencein interfaceQuery
-
isLimiting
public boolean isLimiting()- Specified by:
isLimitingin interfaceQuery- Returns:
- true if the query has a limit on the max number of results.
-
getMaxResults
Description copied from interface:Queryreturn the max of results. Must not return null whenQuery.isLimiting()returns true.- Specified by:
getMaxResultsin interfaceQuery
-
setMaxResults
-
setHighlightQuery
Description copied from interface:QuerySets theHighlightQuery.- Specified by:
setHighlightQueryin interfaceQuery- Parameters:
highlightQuery- the query to set
-
getHighlightQuery
- Specified by:
getHighlightQueryin interfaceQuery- Returns:
- the optional set
HighlightQuery.
-
setTrackTotalHits
Description copied from interface:QuerySets the flag whether to set the Track_total_hits parameter on queries- Specified by:
setTrackTotalHitsin interfaceQuery- Parameters:
trackTotalHits- the value to set.
-
getTrackTotalHits
Description copied from interface:QuerySets the flag whether to set the Track_total_hits parameter on queries- Specified by:
getTrackTotalHitsin interfaceQuery- Returns:
- the set value.
-
setTrackTotalHitsUpTo
Description copied from interface:QuerySets the maximum value up to which total hits are tracked. Only relevant if #getTrackTotalHits is null- Specified by:
setTrackTotalHitsUpToin interfaceQuery- Parameters:
trackTotalHitsUpTo- max limit for trackTotalHits
-
getTrackTotalHitsUpTo
Description copied from interface:QueryGets the maximum value up to which total hits are tracked. Only relevant if #getTrackTotalHits is null- Specified by:
getTrackTotalHitsUpToin interfaceQuery- Returns:
- max limit for trackTotalHits
-
getScrollTime
Description copied from interface:QueryFor 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:
getScrollTimein interfaceQuery- Returns:
- the scrolltime settings
-
setScrollTime
Description copied from interface:QueryFor queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.- Specified by:
setScrollTimein interfaceQuery- Parameters:
scrollTime- the scrolltime settings
-
getTimeout
Description copied from interface:QueryGet the query timeout.- Specified by:
getTimeoutin interfaceQuery- Returns:
- null if not set
-
setTimeout
set the query timeout- Since:
- 4.2
-
getExplain
public boolean getExplain()- Specified by:
getExplainin 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:QuerySets the setSearchAfter objects for this query.- Specified by:
setSearchAfterin interfaceQuery- Parameters:
searchAfter- the setSearchAfter objects. These are obtained withSearchHit.getSortValues()from a search result.
-
getSearchAfter
- Specified by:
getSearchAfterin interfaceQuery- Returns:
- the search_after objects.
-
addRescorerQuery
Description copied from interface:QueryAdds aRescorerQuery.- Specified by:
addRescorerQueryin interfaceQuery- Parameters:
rescorerQuery- the query to add to the list of rescorer queries, must not be null
-
setRescorerQueries
Description copied from interface:QuerySets theRescorerQuery.- Specified by:
setRescorerQueriesin interfaceQuery- Parameters:
rescorerQueryList- list of rescorer queries set, must not be null.
-
getRescorerQueries
Description copied from interface:Queryget the list ofRescorerQuerys- Specified by:
getRescorerQueriesin interfaceQuery
-
setRequestCache
Description copied from interface:Querysets the request_cache value for the query.- Specified by:
setRequestCachein interfaceQuery- Parameters:
value- new value
-
getRequestCache
- Specified by:
getRequestCachein interfaceQuery- Returns:
- the request_cache value for this query.
-
addRuntimeField
Description copied from interface:QueryAdds a runtime field to the query.- Specified by:
addRuntimeFieldin interfaceQuery- Parameters:
runtimeField- the runtime field definition, must not be null
-
getRuntimeFields
- Specified by:
getRuntimeFieldsin interfaceQuery- Returns:
- the runtime fields for this query. May be empty but not null
-
getIndicesBoost
- Specified by:
getIndicesBoostin interfaceQuery
-
getPointInTime
- Specified by:
getPointInTimein 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:Queryreturns 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:
getReactiveBatchSizein interfaceQuery- Returns:
- the batch size, defaults to 500 in
BaseQuery
-
setReactiveBatchSize
- Since:
- 5.1
-
getAllowNoIndices
- Specified by:
getAllowNoIndicesin interfaceQuery
-
getExpandWildcards
- Specified by:
getExpandWildcardsin interfaceQuery
-
getDocValueFields
- Specified by:
getDocValueFieldsin interfaceQuery- Returns:
- a possible empty list of docvalue_field values to be set on the query.
- Since:
- 5.1
-
setDocValueFields
- Since:
- 5.1
-
getScriptedFields
- Specified by:
getScriptedFieldsin interfaceQuery- Returns:
- the list of scripted fields for the query
-