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 recordValue class combining an id with a routing value.static final recordDesscribes the point in time parameters for a querystatic enum -
Field Summary
Fields -
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.<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 requeststatic QueryfindAll()Get aQuerythat matches all documents in the index.@Nullable Boolean@Nullable EnumSet<IndicesOptions.WildcardStates> default booleanGet fields to be returned as part of search requestdefault Optional<HighlightQuery> @Nullable Collection<String> getIds()@Nullable List<IndexBoost> @Nullable IndicesOptionsGet indices optionsdefault @Nullable Integerreturn the max of results.floatGet minimum scoreGet page settings if defineddefault @Nullable Query.PointInTime@Nullable StringGet preferencedefault Integerreturns the number of documents that are requested when the reactive code does a batched search operation.@Nullable Booleandefault List<RescorerQuery> get 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.default booleandefault booleanstatic QuerymultiGetQuery(Collection<String> ids) Utility method to get a query for a multiget requeststatic QuerymultiGetQueryWithRouting(List<Query.IdWithRouting> idsWithRouting) Utility method to get a query for a multiget requestvoidSet fields to be returned as part of search requestvoidsetHighlightQuery(HighlightQuery highlightQuery) Sets theHighlightQuery.<T extends Query>
TsetPageable(Pageable pageable) restrict result to entries on given page.voidsetPreference(String preference) Add preference filter to be added as part of search requestvoidsetRequestCache(@Nullable Boolean value) sets the request_cache value for the query.voidsetRescorerQueries(List<RescorerQuery> rescorerQueryList) Sets theRescorerQuery.voidsetScrollTime(@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.voidsetStoredFields(@Nullable List<String> storedFields) Set stored fields to be returned as part of search requestvoidsetTrackTotalHits(@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.
-
Field Details
-
DEFAULT_PAGE_SIZE
static final int DEFAULT_PAGE_SIZE- See Also:
-
DEFAULT_PAGE
-
-
Method Details
-
findAll
-
setPageable
-
getPageable
-
addSort
-
getSort
@Nullable Sort getSort()- Returns:
- null if not set
-
addFields
Add fields to be added as part of search request- Parameters:
fields-
-
getFields
-
setFields
-
addStoredFields
Add stored fields to be added as part of search request- Parameters:
storedFields-- Since:
- 4.4
-
getStoredFields
-
setStoredFields
-
addSourceFilter
Add source filter to be added as part of search request- Parameters:
sourceFilter-
-
getSourceFilter
@Nullable 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
@Nullable Collection<String> 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
-
getSearchType
-
getIndicesOptions
-
getPreference
-
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
@Nullable Boolean 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
@Nullable Integer 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
@Nullable Duration 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
-
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
-
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
-
setRequestCache
sets the request_cache value for the query.- Parameters:
value- new value- Since:
- 4.3
-
getRequestCache
@Nullable Boolean 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
@Nullable List<IndexBoost> getIndicesBoost()- Since:
- 4.4
-
getPointInTime
- Returns:
- the point in time id to use in the query
- Since:
- 5.0
-
getReactiveBatchSize
-
getAllowNoIndices
@Nullable Boolean getAllowNoIndices()- Since:
- 5.1
-
getExpandWildcards
@Nullable EnumSet<IndicesOptions.WildcardStates> 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
-
getRequestSize
Integer getRequestSize()- 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.
- Since:
- 5.4.8 5.5.2
-