public class ElasticsearchTemplate extends AbstractElasticsearchTemplate
ElasticsearchOperations using the new
Elasticsearch client.| Modifier and Type | Class and Description |
|---|---|
static interface |
ElasticsearchTemplate.ClientCallback<T>
Callback interface to be used with
execute(ElasticsearchTemplate.ClientCallback) for operating directly on
the ElasticsearchClient. |
AbstractElasticsearchTemplate.DocumentCallback<T>, AbstractElasticsearchTemplate.ReadDocumentCallback<T>, AbstractElasticsearchTemplate.ReadSearchDocumentResponseCallback<T>, AbstractElasticsearchTemplate.ReadSearchScrollDocumentResponseCallback<T>, AbstractElasticsearchTemplate.SearchDocumentResponseCallback<T>elasticsearchConverter, entityCallbacks, entityOperations, refreshPolicy, routingResolver| Constructor and Description |
|---|
ElasticsearchTemplate(co.elastic.clients.elasticsearch.ElasticsearchClient 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(co.elastic.clients.elasticsearch.core.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 indexCoordinates) |
protected <T> SearchHits<T> |
doSearch(MoreLikeThisQuery query,
Class<T> clazz,
IndexCoordinates index) |
<T> T |
execute(ElasticsearchTemplate.ClientCallback<T> callback)
Execute a callback with the
ElasticsearchClient and provide exception translation. |
<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 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. |
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 |
protected void |
searchScrollClear(List<String> scrollIds) |
protected <T> SearchScrollHits<T> |
searchScrollContinue(String scrollId,
long scrollTimeInMillis,
Class<T> clazz,
IndexCoordinates index) |
protected <T> SearchScrollHits<T> |
searchScrollStart(long scrollTimeInMillis,
Query query,
Class<T> clazz,
IndexCoordinates index) |
String |
submitReindex(ReindexRequest reindexRequest)
Submits a reindex task.
|
UpdateResponse |
update(UpdateQuery updateQuery,
IndexCoordinates index)
Partial update of the document.
|
ByQueryResponse |
updateByQuery(UpdateQuery updateQuery,
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, bulkUpdatepublic ElasticsearchTemplate(co.elastic.clients.elasticsearch.ElasticsearchClient client,
ElasticsearchConverter elasticsearchConverter)
protected AbstractElasticsearchTemplate doCopy()
AbstractElasticsearchTemplatedoCopy in class AbstractElasticsearchTemplatepublic 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.@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)public void bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index)
DocumentOperationsqueries - the queries to execute in bulkbulkOptions - options to be added to the bulk requestpublic 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 updateQuery, IndexCoordinates index)
DocumentOperationsupdateQuery - query defining the updateindex - the index where to update the recordspublic ByQueryResponse updateByQuery(UpdateQuery updateQuery, IndexCoordinates index)
DocumentOperationsupdateQuery - query defining the update, must not be nullindex - the index where to update the records , must not be nullpublic String doIndex(IndexQuery query, IndexCoordinates indexCoordinates)
doIndex in class AbstractElasticsearchTemplateprotected boolean doExists(String id, IndexCoordinates index)
doExists in class AbstractElasticsearchTemplateprotected String doDelete(String id, @Nullable String routing, IndexCoordinates index)
doDelete in class AbstractElasticsearchTemplatepublic 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 String getClusterVersion()
AbstractElasticsearchTemplategetClusterVersion in class AbstractElasticsearchTemplateprotected String getVendor()
getVendor in class AbstractElasticsearchTemplateprotected String getRuntimeLibraryVersion()
getRuntimeLibraryVersion in class AbstractElasticsearchTemplatepublic 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 AbstractElasticsearchTemplateprotected <T> SearchScrollHits<T> searchScrollStart(long scrollTimeInMillis, Query query, Class<T> clazz, IndexCoordinates index)
searchScrollStart in class AbstractElasticsearchTemplateprotected <T> SearchScrollHits<T> searchScrollContinue(String scrollId, long scrollTimeInMillis, Class<T> clazz, IndexCoordinates index)
searchScrollContinue in class AbstractElasticsearchTemplateprotected void searchScrollClear(List<String> scrollIds)
searchScrollClear in class AbstractElasticsearchTemplatepublic <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 againstpublic <T> T execute(ElasticsearchTemplate.ClientCallback<T> callback)
ElasticsearchClient and provide exception translation.T - the type returned from the callbackcallback - the callback to execute, must not be nullpublic 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 List<IndexedObjectInformation> checkForBulkOperationFailure(co.elastic.clients.elasticsearch.core.BulkResponse bulkResponse)
IndexedObjectInformation from a BulkResponse.bulkResponse - the response to evaluateIndexedObjectInformationsCopyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.