public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
| Modifier and Type | Class and Description |
|---|---|
static interface |
ElasticsearchRestTemplate.ClientCallback<T>
Callback interface to be used with
execute(ClientCallback) for operating directly on
RestHighLevelClient. |
AbstractElasticsearchTemplate.DocumentCallback<T>, AbstractElasticsearchTemplate.ReadDocumentCallback<T>, AbstractElasticsearchTemplate.ReadSearchDocumentResponseCallback<T>, AbstractElasticsearchTemplate.ReadSearchScrollDocumentResponseCallback<T>, AbstractElasticsearchTemplate.SearchDocumentResponseCallback<T>| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.data.elasticsearch.core.RequestFactory |
requestFactory |
elasticsearchConverter, entityCallbacks, entityOperations, refreshPolicy, routingResolver| Constructor and Description |
|---|
ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client) |
ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client,
ElasticsearchConverter elasticsearchConverter) |
| Modifier and Type | Method and Description |
|---|---|
void |
bulkUpdate(List<UpdateQuery> queries,
BulkOptions bulkOptions,
IndexCoordinates index)
Bulk update all objects.
|
protected List<IndexedObjectInformation> |
checkForBulkOperationFailure(org.elasticsearch.action.bulk.BulkResponse bulkResponse)
extract the list of
IndexedObjectInformation from a BulkResponse. |
ClusterOperations |
cluster()
return a
ClusterOperations instance that uses the same client communication setup as this
ElasticsearchOperations instance. |
long |
count(Query query,
Class<?> clazz,
IndexCoordinates index)
return number of elements found by given query
|
ByQueryResponse |
delete(Query query,
Class<?> clazz,
IndexCoordinates index)
Delete all records matching the query.
|
List<IndexedObjectInformation> |
doBulkOperation(List<?> queries,
BulkOptions bulkOptions,
IndexCoordinates index) |
protected AbstractElasticsearchTemplate |
doCopy()
must return a copy of this instance that will for example be used to set a custom routing resolver without
modifying the original object.
|
protected String |
doDelete(String id,
String routing,
IndexCoordinates index) |
protected boolean |
doExists(String id,
IndexCoordinates index) |
String |
doIndex(IndexQuery query,
IndexCoordinates index) |
protected <T> SearchHits<T> |
doSearch(MoreLikeThisQuery query,
Class<T> clazz,
IndexCoordinates index) |
<T> T |
execute(ElasticsearchRestTemplate.ClientCallback<T> callback)
Execute a callback with the
RestHighLevelClient |
<T> T |
get(String id,
Class<T> clazz,
IndexCoordinates index)
Retrieves an object from the index specified in the entity's Document annotation.
|
protected String |
getClusterVersion()
tries to extract the version of the Elasticsearch cluster
|
protected org.elasticsearch.action.search.MultiSearchResponse.Item[] |
getMultiSearchResult(org.elasticsearch.action.search.MultiSearchRequest request) |
org.springframework.data.elasticsearch.core.RequestFactory |
getRequestFactory() |
protected String |
getRuntimeLibraryVersion() |
protected String |
getVendor() |
Query |
idsQuery(List<String> ids)
Creates a
Query to find get all documents with given ids. |
IndexOperations |
indexOps(Class<?> clazz)
get an
IndexOperations that is bound to the given class |
IndexOperations |
indexOps(IndexCoordinates index)
get an
IndexOperations that is bound to the given index |
Query |
matchAllQuery()
Creates a
Query to get all documents. |
<T> List<MultiGetItem<T>> |
multiGet(Query query,
Class<T> clazz,
IndexCoordinates index)
Execute a multiGet against elasticsearch for the given ids.
|
<T> List<SearchHits<T>> |
multiSearch(List<? extends Query> queries,
Class<T> clazz,
IndexCoordinates index)
Execute the multi search query against elasticsearch and return result as
List of SearchHits. |
List<SearchHits<?>> |
multiSearch(List<? extends Query> queries,
List<Class<?>> classes)
Execute the multi search query against elasticsearch and return result as
List of SearchHits. |
List<SearchHits<?>> |
multiSearch(List<? extends Query> queries,
List<Class<?>> classes,
IndexCoordinates index)
Execute the multi search query against elasticsearch and return result as
List of SearchHits. |
protected <R extends org.elasticsearch.action.support.WriteRequest<R>> |
prepareWriteRequest(R request)
Preprocess the write request before it is sent to the server, e.g. by setting the
refresh policy if applicable. |
ReindexResponse |
reindex(ReindexRequest reindexRequest)
Copies documents from a source to a destination.
|
<T> SearchHits<T> |
search(Query query,
Class<T> clazz,
IndexCoordinates index)
Execute the criteria query against elasticsearch and return result as
SearchHits |
void |
searchScrollClear(List<String> scrollIds) |
<T> SearchScrollHits<T> |
searchScrollContinue(String scrollId,
long scrollTimeInMillis,
Class<T> clazz,
IndexCoordinates index) |
<T> SearchScrollHits<T> |
searchScrollStart(long scrollTimeInMillis,
Query query,
Class<T> clazz,
IndexCoordinates index) |
String |
submitReindex(ReindexRequest reindexRequest)
Submits a reindex task.
|
org.elasticsearch.action.search.SearchResponse |
suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion,
Class<?> clazz)
Deprecated.
|
org.elasticsearch.action.search.SearchResponse |
suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion,
IndexCoordinates index)
Does a suggest query
|
UpdateResponse |
update(UpdateQuery query,
IndexCoordinates index)
Partial update of the document.
|
ByQueryResponse |
updateByQuery(UpdateQuery query,
IndexCoordinates index)
Update document(s) by query
|
bulkIndex, bulkIndex, bulkIndex, bulkOperation, bulkUpdate, count, delete, delete, delete, delete, delete, delete, exists, exists, get, getElasticsearchConverter, getEntityCreator, getEntityRouting, getIndexCoordinatesFor, getRefreshPolicy, index, logVersions, maybeCallbackAfterConvert, maybeCallbackAfterLoad, maybeCallbackAfterSave, maybeCallbackAfterSaveWithQueries, maybeCallbackAfterSaveWithQuery, maybeCallbackBeforeConvert, maybeCallbackBeforeConvertWithQueries, maybeCallbackBeforeConvertWithQuery, multiGet, multiSearch, save, save, save, save, save, search, search, search, searchForStream, searchForStream, searchScrollClear, setApplicationContext, setEntityCallbacks, setRefreshPolicy, toArray, updateIndexedObject, updateIndexedObjectsWithQueries, withRoutingclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitstringIdRepresentationbulkIndex, bulkUpdatecount, searchOne, searchOneprotected org.springframework.data.elasticsearch.core.RequestFactory requestFactory
public ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client)
public ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client,
ElasticsearchConverter elasticsearchConverter)
protected AbstractElasticsearchTemplate doCopy()
AbstractElasticsearchTemplatedoCopy in class AbstractElasticsearchTemplatepublic org.springframework.data.elasticsearch.core.RequestFactory getRequestFactory()
public IndexOperations indexOps(Class<?> clazz)
ElasticsearchOperationsIndexOperations that is bound to the given classpublic IndexOperations indexOps(IndexCoordinates index)
ElasticsearchOperationsIndexOperations that is bound to the given indexpublic ClusterOperations cluster()
ElasticsearchOperationsClusterOperations instance that uses the same client communication setup as this
ElasticsearchOperations instance.public String doIndex(IndexQuery query, IndexCoordinates index)
doIndex in class AbstractElasticsearchTemplate@Nullable public <T> T get(String id, Class<T> clazz, IndexCoordinates index)
DocumentOperationsid - the id of the objectclazz - the entity class,index - the index from which the object is read.public <T> List<MultiGetItem<T>> multiGet(Query query, Class<T> clazz, IndexCoordinates index)
DocumentOperationsquery - the query defining the ids of the objects to getclazz - the type of the object to be returnedindex - the index(es) from which the objects are read.MultiGetItemsQuery.multiGetQuery(Collection),
Query.multiGetQueryWithRouting(List)protected boolean doExists(String id, IndexCoordinates index)
doExists in class AbstractElasticsearchTemplatepublic void bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index)
DocumentOperationsqueries - the queries to execute in bulkbulkOptions - options to be added to the bulk requestprotected String doDelete(String id, @Nullable String routing, IndexCoordinates index)
doDelete in class AbstractElasticsearchTemplatepublic ByQueryResponse delete(Query query, Class<?> clazz, IndexCoordinates index)
DocumentOperationsquery - query defining the objectsclazz - The entity class, must be annotated with
Documentindex - the index from which to deletepublic UpdateResponse update(UpdateQuery query, IndexCoordinates index)
DocumentOperationsquery - query defining the updateindex - the index where to update the recordspublic ByQueryResponse updateByQuery(UpdateQuery query, IndexCoordinates index)
DocumentOperationsquery - query defining the update, must not be nullindex - the index where to update the records , must not be nullpublic ReindexResponse reindex(ReindexRequest reindexRequest)
DocumentOperationsreindexRequest - reindex request parameterspublic String submitReindex(ReindexRequest reindexRequest)
DocumentOperationsreindexRequest - reindex request parameterspublic List<IndexedObjectInformation> doBulkOperation(List<?> queries, BulkOptions bulkOptions, IndexCoordinates index)
doBulkOperation in class AbstractElasticsearchTemplateprotected <R extends org.elasticsearch.action.support.WriteRequest<R>> R prepareWriteRequest(R request)
refresh policy if applicable.R - the request typerequest - must not be null.WriteRequest.protected List<IndexedObjectInformation> checkForBulkOperationFailure(org.elasticsearch.action.bulk.BulkResponse bulkResponse)
IndexedObjectInformation from a BulkResponse.bulkResponse - the response to evaluateIndexedObjectInformationspublic long count(Query query, @Nullable Class<?> clazz, IndexCoordinates index)
SearchOperationsquery - the query to executeclazz - the entity clazz used for property mappingindex - the index to run the query againstpublic <T> SearchHits<T> search(Query query, Class<T> clazz, IndexCoordinates index)
SearchOperationsSearchHitsT - element return typequery - the query to executeclazz - the entity clazz used for property mappingindex - the index to run the query againstprotected <T> SearchHits<T> doSearch(MoreLikeThisQuery query, Class<T> clazz, IndexCoordinates index)
doSearch in class AbstractElasticsearchTemplatepublic <T> SearchScrollHits<T> searchScrollStart(long scrollTimeInMillis, Query query, Class<T> clazz, IndexCoordinates index)
searchScrollStart in class AbstractElasticsearchTemplatepublic <T> SearchScrollHits<T> searchScrollContinue(String scrollId, long scrollTimeInMillis, Class<T> clazz, IndexCoordinates index)
searchScrollContinue in class AbstractElasticsearchTemplatepublic void searchScrollClear(List<String> scrollIds)
searchScrollClear in class AbstractElasticsearchTemplatepublic org.elasticsearch.action.search.SearchResponse suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion,
IndexCoordinates index)
SearchOperationssuggestion - the queryindex - the index to run the query againstpublic <T> List<SearchHits<T>> multiSearch(List<? extends Query> queries, Class<T> clazz, IndexCoordinates index)
SearchOperationsList of SearchHits.T - element return typequeries - the queries to executeclazz - the entity clazz used for property mappingindex - the index to run the query againstpublic List<SearchHits<?>> multiSearch(List<? extends Query> queries, List<Class<?>> classes)
SearchOperationsList of SearchHits.queries - the queries to executeclasses - the entity classespublic List<SearchHits<?>> multiSearch(List<? extends Query> queries, List<Class<?>> classes, IndexCoordinates index)
SearchOperationsList of SearchHits.queries - the queries to executeclasses - the entity classes used for property mappingindex - the index to run the query againstprotected org.elasticsearch.action.search.MultiSearchResponse.Item[] getMultiSearchResult(org.elasticsearch.action.search.MultiSearchRequest request)
public <T> T execute(ElasticsearchRestTemplate.ClientCallback<T> callback)
RestHighLevelClientT - the type returned from the callbackcallback - the callback to execute, must not be nullprotected String getClusterVersion()
AbstractElasticsearchTemplategetClusterVersion in class AbstractElasticsearchTemplatepublic Query matchAllQuery()
SearchOperationsQuery to get all documents. Must be implemented by the concrete implementations to provide an
appropriate query using the respective client.public Query idsQuery(List<String> ids)
SearchOperationsQuery to find get all documents with given ids. Must be implemented by the concrete
implementations to provide an appropriate query using the respective client.ids - the list of ids must not be nullprotected String getVendor()
getVendor in class AbstractElasticsearchTemplateprotected String getRuntimeLibraryVersion()
getRuntimeLibraryVersion in class AbstractElasticsearchTemplate@Deprecated public org.elasticsearch.action.search.SearchResponse suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion, Class<?> clazz)
SearchOperationssuggestion - the queryclazz - the entity classCopyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.