Interface SearchOperations
- All Known Subinterfaces:
ElasticsearchOperations
- All Known Implementing Classes:
AbstractElasticsearchTemplate
,ElasticsearchTemplate
public interface SearchOperations
The operations for the
Elasticsearch Document
APIs.
- Since:
- 4.0
- Author:
- Peter-Josef Meisch, Sascha Woo, Hamid Rahimi
-
Method Summary
Modifier and TypeMethodDescriptionclosePointInTime
(String pit) Closes a point in timelong
return number of elements found by given querylong
count
(Query query, Class<?> clazz, IndexCoordinates index) return number of elements found by given querydefault long
count
(Query query, IndexCoordinates index) Return number of elements found by given query.Creates aQuery
to find get all documents with given ids.Creates aQuery
to get all documents.<T> List<SearchHits<T>>
multiSearch
(List<? extends Query> queries, Class<T> clazz) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.<T> List<SearchHits<T>>
multiSearch
(List<? extends Query> queries, Class<T> clazz, IndexCoordinates index) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.List<SearchHits<?>>
multiSearch
(List<? extends Query> queries, List<Class<?>> classes) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.List<SearchHits<?>>
multiSearch
(List<? extends Query> queries, List<Class<?>> classes, List<IndexCoordinates> indexes) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.List<SearchHits<?>>
multiSearch
(List<? extends Query> queries, List<Class<?>> classes, IndexCoordinates index) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.default String
openPointInTime
(IndexCoordinates index, Duration keepAlive) Opens a point in time (pit) in Elasticsearch.openPointInTime
(IndexCoordinates index, Duration keepAlive, Boolean ignoreUnavailable) Opens a point in time (pit) in Elasticsearch.queryBuilderWithIds
(List<String> ids) Creates aBaseQueryBuilder
that has the given ids setto the parameter value.<T> SearchHits<T>
search
(MoreLikeThisQuery query, Class<T> clazz) more like this query to search for documents that are "like" a specific document.<T> SearchHits<T>
search
(MoreLikeThisQuery query, Class<T> clazz, IndexCoordinates index) more like this query to search for documents that are "like" a specific document.<T> SearchHits<T>
Execute the criteria query against elasticsearch and return result asSearchHits
<T> SearchHits<T>
search
(Query query, Class<T> clazz, IndexCoordinates index) Execute the criteria query against elasticsearch and return result asSearchHits
<T> SearchHitsIterator<T>
searchForStream
(Query query, Class<T> clazz) Executes the givenQuery
against elasticsearch and return result asSearchHitsIterator
.<T> SearchHitsIterator<T>
searchForStream
(Query query, Class<T> clazz, IndexCoordinates index) Executes the givenQuery
against elasticsearch and return result asSearchHitsIterator
.default <T> SearchHit<T>
Execute the query against elasticsearch and return the first returned object.default <T> SearchHit<T>
searchOne
(Query query, Class<T> clazz, IndexCoordinates index) Execute the query against elasticsearch and return the first returned object.
-
Method Details
-
count
Return number of elements found by given query.- Parameters:
query
- the query to executeindex
- the index to run the query against- Returns:
- count
-
count
return number of elements found by given query- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mapping and index name extraction- Returns:
- count
-
count
return number of elements found by given query- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query against- Returns:
- count
-
searchOne
Execute the query against elasticsearch and return the first returned object.- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mapping and indexname extraction- Returns:
- the first found object
-
searchOne
Execute the query against elasticsearch and return the first returned object.- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query against- Returns:
- the first found object
-
multiSearch
Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.- Type Parameters:
T
- element return type- Parameters:
queries
- the queries to executeclazz
- the entity clazz- Returns:
- list of SearchHits
- Since:
- 4.1
-
multiSearch
<T> List<SearchHits<T>> multiSearch(List<? extends Query> queries, Class<T> clazz, IndexCoordinates index) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.- Type Parameters:
T
- element return type- Parameters:
queries
- the queries to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query against- Returns:
- list of SearchHits
-
multiSearch
Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.- Parameters:
queries
- the queries to executeclasses
- the entity classes- Returns:
- list of SearchHits
- Since:
- 4.1
-
multiSearch
List<SearchHits<?>> multiSearch(List<? extends Query> queries, List<Class<?>> classes, IndexCoordinates index) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.- Parameters:
queries
- the queries to executeclasses
- the entity classes used for property mappingindex
- the index to run the queries against- Returns:
- list of SearchHits
-
multiSearch
List<SearchHits<?>> multiSearch(List<? extends Query> queries, List<Class<?>> classes, List<IndexCoordinates> indexes) Execute the multi search query against elasticsearch and return result asList
ofSearchHits
.- Parameters:
queries
- the queries to executeclasses
- the entity classes used for property mappingindexes
- the indexes to run the queries against- Returns:
- list of SearchHits
- Since:
- 5.1
-
search
Execute the criteria query against elasticsearch and return result asSearchHits
- Type Parameters:
T
- element return type- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mapping and index name extraction- Returns:
- SearchHits containing the list of found objects
-
search
Execute the criteria query against elasticsearch and return result asSearchHits
- Type Parameters:
T
- element return type- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query against- Returns:
- SearchHits containing the list of found objects
-
search
more like this query to search for documents that are "like" a specific document.- Type Parameters:
T
- element return type- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mapping and index name extraction- Returns:
- SearchHits containing the list of found objects
-
search
more like this query to search for documents that are "like" a specific document.- Type Parameters:
T
- element return type- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query against- Returns:
- SearchHits containing the list of found objects
-
searchForStream
Executes the givenQuery
against elasticsearch and return result asSearchHitsIterator
.- Type Parameters:
T
- element return type- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mapping and index name extraction- Returns:
- a
SearchHitsIterator
that wraps an Elasticsearch scroll context that needs to be closed. The try-with-resources construct should be used to ensure that the close method is invoked after the operations are completed.
-
searchForStream
Executes the givenQuery
against elasticsearch and return result asSearchHitsIterator
.- Type Parameters:
T
- element return type- Parameters:
query
- the query to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query against- Returns:
- a
SearchHitsIterator
that wraps an Elasticsearch scroll context that needs to be closed. The try-with-resources construct should be used to ensure that the close method is invoked after the operations are completed.
-
matchAllQuery
Query matchAllQuery()Creates aQuery
to get all documents. Must be implemented by the concrete implementations to provide an appropriate query using the respective client.- Returns:
- a query to find all documents
- Since:
- 4.3
-
idsQuery
Creates aQuery
to find get all documents with given ids. Must be implemented by the concrete implementations to provide an appropriate query using the respective client.- Parameters:
ids
- the list of ids must not be null- Returns:
- query returning the documents with the given ids
- Since:
- 4.3
-
queryBuilderWithIds
Creates aBaseQueryBuilder
that has the given ids setto the parameter value. No other properties of the bulder are set.- Parameters:
ids
- the list of ids must not be null- Returns:
- query returning the documents with the given ids
- Since:
- 5.2
-
openPointInTime
Opens a point in time (pit) in Elasticsearch.- Parameters:
index
- the index name(s) to usekeepAlive
- the duration the pit shoult be kept alive- Returns:
- the pit identifier
- Since:
- 5.0
-
openPointInTime
Opens a point in time (pit) in Elasticsearch.- Parameters:
index
- the index name(s) to usekeepAlive
- the duration the pit shoult be kept aliveignoreUnavailable
- if {$literal true} the call will fail if any of the indices is missing or closed- Returns:
- the pit identifier
- Since:
- 5.0
-
closePointInTime
Closes a point in time- Parameters:
pit
- the pit identifier as returned byopenPointInTime(IndexCoordinates, Duration, Boolean)
- Returns:
- true on success
- Since:
- 5.0
-