Class BaseQuery
java.lang.Object
org.springframework.data.elasticsearch.core.query.BaseQuery
- All Implemented Interfaces:
Query
- Direct Known Subclasses:
CriteriaQuery, NativeQuery, SearchTemplateQuery, StringQuery
-
Nested Class Summary
Nested classes/interfaces inherited from interface Query
Query.IdWithRouting, Query.PointInTime, Query.SearchType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable HighlightQueryprotected @Nullable Collection<String> protected List<Query.IdWithRouting> static final intprotected @Nullable List<IndexBoost> protected @Nullable IndicesOptionsprotected @Nullable Integerprotected floatprotected Pageableprotected @Nullable Query.PointInTimeprotected @Nullable Stringprotected @Nullable Booleanprotected List<RescorerQuery> protected @Nullable Stringprotected List<RuntimeField> protected @Nullable Durationprotected @Nullable Query.SearchTypeprotected @Nullable Sortprotected @Nullable SourceFilterprotected @Nullable Durationprotected booleanprotected @Nullable IntegerFields inherited from interface Query
DEFAULT_PAGE, DEFAULT_PAGE_SIZE -
Constructor Summary
ConstructorsModifierConstructorDescription<Q extends BaseQuery, B extends BaseQueryBuilder<Q,B>> BaseQuery(BaseQueryBuilder<Q, B> builder) -
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.voidaddScriptedField(ScriptedField scriptedField) 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 request@Nullable BooleanbooleanGet fields to be returned as part of search request@Nullable Collection<String> getIds()@Nullable List<IndexBoost> @Nullable IndicesOptionsGet indices options@Nullable Integerreturn the max of results.floatGet minimum scoreGet page settings if defined@Nullable Query.PointInTime@Nullable StringGet preferencereturns the number of documents that are requested when the reactive code does a batched search operation.@Nullable Booleanget the list ofRescorerQuerys@Nullable StringgetRoute()Get route@Nullable DurationFor queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.@Nullable Query.SearchTypeType of search@Nullable SortgetSort()@Nullable SourceFilterGet 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 request@Nullable DurationGet the query timeout.booleanGet if scores will be computed and tracked, regardless of whether sorting on a field.@Nullable BooleanSets the flag whether to set the Track_total_hits parameter on queries@Nullable IntegerGets 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(@Nullable 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(@Nullable 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(@Nullable Boolean value) sets the request_cache value for the query.voidsetRescorerQueries(List<RescorerQuery> rescorerQueryList) Sets theRescorerQuery.voidvoidsetScrollTime(@Nullable Duration scrollTime) For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete queries.voidsetSearchAfter(@Nullable List<Object> searchAfter) Sets the setSearchAfter objects for this query.voidsetSearchType(@Nullable Query.SearchType searchType) voidvoidsetStoredFields(@Nullable List<String> storedFields) Set stored fields to be returned as part of search requestvoidsetTimeout(@Nullable Duration timeout) set the query timeoutvoidsetTrackScores(boolean trackScores) Configures whether to track scores.voidsetTrackTotalHits(@Nullable Boolean trackTotalHits) Sets the flag whether to set the Track_total_hits parameter on queriesvoidsetTrackTotalHitsUpTo(@Nullable Integer trackTotalHitsUpTo) Sets the maximum value up to which total hits are tracked.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Query
hasScrollTime
-
Field Details
-
INDEX_MAX_RESULT_WINDOW
public static final int INDEX_MAX_RESULT_WINDOW- See Also:
-
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
public <Q extends BaseQuery, B extends BaseQueryBuilder<Q,B>> BaseQuery(BaseQueryBuilder<Q, B> builder)
-
-
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- Parameters:
pageable-- Returns:
-
addFields
-
getFields
-
setFields
-
addStoredFields
Description copied from interface:QueryAdd stored fields to be added as part of search request- Specified by:
addStoredFieldsin interfaceQuery- Parameters:
storedFields-
-
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- Parameters:
storedFields-
-
addSourceFilter
Description copied from interface:QueryAdd source filter to be added as part of search request- Specified by:
addSourceFilterin interfaceQuery- Parameters:
sourceFilter-
-
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
-
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
-
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- Parameters:
preference-
-
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
-
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
-
addScriptedField
- Since:
- 5.2
-
getScriptedFields
- Specified by:
getScriptedFieldsin interfaceQuery- Returns:
- the list of scripted fields for the query
-
getRequestSize
- Specified by:
getRequestSizein interfaceQuery- Returns:
- the number of documents that should be requested from Elasticsearch in this query. Depends wether a Pageable and/or maxResult size is set on the query.
-