Interface SearchOperations
- All Known Subinterfaces:
ElasticsearchOperations
- All Known Implementing Classes:
AbstractElasticsearchTemplate,ElasticsearchRestTemplate,ElasticsearchTemplate
public interface SearchOperations
The operations for the
Elasticsearch Document
APIs.
- Since:
- 4.0
- Author:
- Peter-Josef Meisch, Sascha Woo
-
Method Summary
Modifier and TypeMethodDescriptionlongreturn number of elements found by given querylongcount(Query query, Class<?> clazz, IndexCoordinates index) return number of elements found by given querydefault longcount(Query query, IndexCoordinates index) Return number of elements found by given query.Creates aQueryto find get all documents with given ids.Creates aQueryto 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 asListofSearchHits.<T> List<SearchHits<T>>multiSearch(List<? extends Query> queries, Class<T> clazz, IndexCoordinates index) Execute the multi search query against elasticsearch and return result asListofSearchHits.List<SearchHits<?>>multiSearch(List<? extends Query> queries, List<Class<?>> classes) Execute the multi search query against elasticsearch and return result asListofSearchHits.List<SearchHits<?>>multiSearch(List<? extends Query> queries, List<Class<?>> classes, IndexCoordinates index) Execute the multi search query against elasticsearch and return result asListofSearchHits.<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 givenQueryagainst elasticsearch and return result asSearchHitsIterator.<T> SearchHitsIterator<T>searchForStream(Query query, Class<T> clazz, IndexCoordinates index) Executes the givenQueryagainst 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.default org.elasticsearch.action.search.SearchResponseDeprecated.default org.elasticsearch.action.search.SearchResponsesuggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion, IndexCoordinates index) Deprecated.since 4.3 use aNativeSearchQueryBuilderwithNativeSearchQueryBuilder.withSuggestBuilder(SuggestBuilder), callsearch(Query, Class)and get the suggest fromSearchHits.getSuggest()
-
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
-
suggest
@Deprecated default org.elasticsearch.action.search.SearchResponse suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion, Class<?> clazz) Deprecated.since 4.3 use aNativeSearchQueryBuilderwithNativeSearchQueryBuilder.withSuggestBuilder(SuggestBuilder), callsearch(Query, Class)and get the suggest fromSearchHits.getSuggest()Does a suggest query- Parameters:
suggestion- the queryclazz- the entity class- Returns:
- the suggest response
- Since:
- 4.1
-
suggest
@Deprecated default org.elasticsearch.action.search.SearchResponse suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion, IndexCoordinates index) Deprecated.since 4.3 use aNativeSearchQueryBuilderwithNativeSearchQueryBuilder.withSuggestBuilder(SuggestBuilder), callsearch(Query, Class)and get the suggest fromSearchHits.getSuggest()Does a suggest query- Parameters:
suggestion- the queryindex- the index to run the query against- Returns:
- the suggest response
-
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 asListofSearchHits.- 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 asListofSearchHits.- 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 asListofSearchHits.- 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 asListofSearchHits.- Parameters:
queries- the queries to executeclasses- the entity classes used for property mappingindex- the index to run the query against- Returns:
- list of SearchHits
-
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 givenQueryagainst 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
SearchHitsIteratorthat 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 givenQueryagainst 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
SearchHitsIteratorthat 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 aQueryto 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 aQueryto 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
-
NativeSearchQueryBuilderwithNativeSearchQueryBuilder.withSuggestBuilder(SuggestBuilder), callsearch(Query, Class)and get the suggest fromSearchHits.getSuggest()