Class ReactiveElasticsearchTemplate
java.lang.Object
org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate
org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchTemplate
- All Implemented Interfaces:
Aware
,ApplicationContextAware
,ReactiveDocumentOperations
,ReactiveElasticsearchOperations
,ReactiveSearchOperations
Implementation of
ReactiveElasticsearchOperations
using the new
Elasticsearch client.- Since:
- 4.4
- Author:
- Peter-Josef Meisch
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate
AbstractReactiveElasticsearchTemplate.DocumentCallback<T>, AbstractReactiveElasticsearchTemplate.Entities<T>, AbstractReactiveElasticsearchTemplate.IndexResponseMetaData, AbstractReactiveElasticsearchTemplate.ReadDocumentCallback<T>, AbstractReactiveElasticsearchTemplate.ReadSearchDocumentCallback<T>, AbstractReactiveElasticsearchTemplate.SearchDocumentCallback<T>
Nested classes/interfaces inherited from interface org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations
ReactiveElasticsearchOperations.ClusterClientCallback<T extends org.reactivestreams.Publisher<?>>, ReactiveElasticsearchOperations.IndicesClientCallback<T extends org.reactivestreams.Publisher<?>>
-
Field Summary
Fields inherited from class org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate
converter, entityCallbacks, entityOperations, mappingContext, QUERY_LOGGER, refreshPolicy, routingResolver
-
Constructor Summary
ConstructorDescriptionReactiveElasticsearchTemplate
(ReactiveElasticsearchClient client, ElasticsearchConverter converter) -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Flux<? extends AggregationContainer<?>>
aggregate
(Query query, Class<?> entityType, IndexCoordinates index) Perform an aggregation specified by the givenquery
.reactor.core.publisher.Mono<Void>
bulkUpdate
(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Bulk update all objects.cluster()
return aReactiveClusterOperations
instance that uses the same client communication setup as this ElasticsearchOperations instance.reactor.core.publisher.Mono<ByQueryResponse>
delete
(Query query, Class<?> entityType, IndexCoordinates index) Delete the documents matching the givenQuery
extracting index from entity metadata.protected ReactiveElasticsearchTemplate
doCopy()
protected reactor.core.publisher.Mono<Long>
doCount
(Query query, Class<?> entityType, IndexCoordinates index) protected reactor.core.publisher.Mono<String>
doDeleteById
(String id, String routing, IndexCoordinates index) protected reactor.core.publisher.Mono<Boolean>
doExists
(String id, IndexCoordinates index) protected reactor.core.publisher.Flux<SearchDocument>
doFind
(Query query, Class<?> clazz, IndexCoordinates index) protected <T> reactor.core.publisher.Mono<SearchDocumentResponse>
doFindForResponse
(Query query, Class<?> clazz, IndexCoordinates index) protected <T> reactor.core.publisher.Mono<reactor.util.function.Tuple2<T,
AbstractReactiveElasticsearchTemplate.IndexResponseMetaData>> doIndex
(T entity, IndexCoordinates index) <T> org.reactivestreams.Publisher<T>
execute
(org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchTemplate.ClientCallback<org.reactivestreams.Publisher<T>> callback) Execute a callback with theReactiveElasticsearchClient
and provide exception translation.<T> org.reactivestreams.Publisher<T>
execute
(ReactiveElasticsearchOperations.ClientCallback<org.reactivestreams.Publisher<T>> callback) Deprecated.<T> org.reactivestreams.Publisher<T>
executeWithClusterClient
(ReactiveElasticsearchOperations.ClusterClientCallback<org.reactivestreams.Publisher<T>> callback) Execute within aReactiveElasticsearchOperations.ClusterClientCallback
managing resources and translating errors.<T> org.reactivestreams.Publisher<T>
executeWithIndicesClient
(ReactiveElasticsearchOperations.IndicesClientCallback<org.reactivestreams.Publisher<T>> callback) Execute within aReactiveElasticsearchOperations.IndicesClientCallback
managing resources and translating errors.<T> reactor.core.publisher.Mono<T>
get
(String id, Class<T> entityType, IndexCoordinates index) Fetch the entity with given id.reactor.core.publisher.Mono<String>
reactor.core.publisher.Mono<String>
reactor.core.publisher.Mono<String>
Creates aQuery
to find get all documents with given ids.Creates aReactiveIndexOperations
that is bound to the given classindexOps
(IndexCoordinates index) Creates aReactiveIndexOperations
that is bound to the given indexCreates aQuery
to find all documents.<T> reactor.core.publisher.Flux<MultiGetItem<T>>
multiGet
(Query query, Class<T> clazz, IndexCoordinates index) Execute a multiGet against elasticsearch for the given ids.reactor.core.publisher.Mono<ReindexResponse>
reindex
(ReindexRequest reindexRequest) Copies documents from a source to a destination.<T> reactor.core.publisher.Flux<T>
saveAll
(reactor.core.publisher.Mono<? extends Collection<? extends T>> entitiesPublisher, IndexCoordinates index) Index entities in the given index.reactor.core.publisher.Mono<String>
submitReindex
(ReindexRequest reindexRequest) Submits a reindex task.reactor.core.publisher.Mono<UpdateResponse>
update
(UpdateQuery updateQuery, IndexCoordinates index) Partial update of the document.reactor.core.publisher.Mono<ByQueryResponse>
updateByQuery
(UpdateQuery updateQuery, IndexCoordinates index) Update document(s) by query.Methods inherited from class org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate
aggregate, count, count, delete, delete, delete, delete, delete, exists, exists, get, getElasticsearchConverter, getIndexCoordinatesFor, getIndexQuery, getPersistentEntityFor, getRefreshPolicy, logVersions, maybeCallAfterConvert, maybeCallAfterSave, maybeCallbackAfterLoad, maybeCallBeforeConvert, multiGet, save, save, saveAll, search, search, searchForHits, searchForHits, searchForPage, searchForPage, setApplicationContext, setEntityCallbacks, setRefreshPolicy, suggest, suggest, updateIndexedObject, withRouting
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.elasticsearch.core.ReactiveDocumentOperations
bulkUpdate, save, save, saveAll, saveAll
Methods inherited from interface org.springframework.data.elasticsearch.core.ReactiveSearchOperations
count, search, search, searchForHits, searchForHits, searchForPage, searchForPage
-
Constructor Details
-
ReactiveElasticsearchTemplate
public ReactiveElasticsearchTemplate(ReactiveElasticsearchClient client, ElasticsearchConverter converter)
-
-
Method Details
-
doIndex
protected <T> reactor.core.publisher.Mono<reactor.util.function.Tuple2<T,AbstractReactiveElasticsearchTemplate.IndexResponseMetaData>> doIndex(T entity, IndexCoordinates index) - Specified by:
doIndex
in classAbstractReactiveElasticsearchTemplate
-
saveAll
public <T> reactor.core.publisher.Flux<T> saveAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> entitiesPublisher, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperations
Index entities in the given index. If the index is null or empty the index name provided via entity metadata is used.- Parameters:
entitiesPublisher
- must not be null.index
- the target index, must not be null- Returns:
- a
Flux
emitting saved entities.
-
get
public <T> reactor.core.publisher.Mono<T> get(String id, Class<T> entityType, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperations
Fetch the entity with given id.- Parameters:
id
- must not be null.index
- the target index, must not be null- Returns:
- the
Mono
emitting the entity or signalling completion if none found.
-
reindex
Description copied from interface:ReactiveDocumentOperations
Copies documents from a source to a destination. The source can be any existing index, alias, or data stream. The destination must differ from the source. For example, you cannot reindex a data stream into itself. (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)- Parameters:
reindexRequest
- reindex request parameters- Returns:
- a
Mono
emitting the reindex response
-
submitReindex
Description copied from interface:ReactiveDocumentOperations
Submits a reindex task. (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)- Parameters:
reindexRequest
- reindex request parameters- Returns:
- a
Mono
emitting the task id.
-
bulkUpdate
public reactor.core.publisher.Mono<Void> bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperations
Bulk update all objects. Will do update.- Parameters:
queries
- the queries to execute in bulkbulkOptions
- options to be added to the bulk request
-
doDeleteById
protected reactor.core.publisher.Mono<String> doDeleteById(String id, @Nullable String routing, IndexCoordinates index) - Specified by:
doDeleteById
in classAbstractReactiveElasticsearchTemplate
-
multiGet
public <T> reactor.core.publisher.Flux<MultiGetItem<T>> multiGet(Query query, Class<T> clazz, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperations
Execute a multiGet against elasticsearch for the given ids.- Parameters:
query
- 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.- Returns:
- flux with list of
MultiGetItem
s that contain the entities - See Also:
-
doCopy
- Specified by:
doCopy
in classAbstractReactiveElasticsearchTemplate
-
doExists
- Specified by:
doExists
in classAbstractReactiveElasticsearchTemplate
-
delete
public reactor.core.publisher.Mono<ByQueryResponse> delete(Query query, Class<?> entityType, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperations
Delete the documents matching the givenQuery
extracting index from entity metadata.- Parameters:
query
- must not be null.entityType
- must not be null.index
- the target index, must not be null- Returns:
- a
Mono
emitting the number of the removed documents.
-
doFind
protected reactor.core.publisher.Flux<SearchDocument> doFind(Query query, Class<?> clazz, IndexCoordinates index) - Specified by:
doFind
in classAbstractReactiveElasticsearchTemplate
-
doCount
protected reactor.core.publisher.Mono<Long> doCount(Query query, Class<?> entityType, IndexCoordinates index) - Specified by:
doCount
in classAbstractReactiveElasticsearchTemplate
-
doFindForResponse
protected <T> reactor.core.publisher.Mono<SearchDocumentResponse> doFindForResponse(Query query, Class<?> clazz, IndexCoordinates index) - Specified by:
doFindForResponse
in classAbstractReactiveElasticsearchTemplate
-
aggregate
public reactor.core.publisher.Flux<? extends AggregationContainer<?>> aggregate(Query query, Class<?> entityType, IndexCoordinates index) Description copied from interface:ReactiveSearchOperations
Perform an aggregation specified by the givenquery
.- Parameters:
query
- must not be null.entityType
- must not be null.index
- the target index, must not be null- Returns:
- a
Flux
emitting matching aggregations one by one.
-
getVendor
- Specified by:
getVendor
in classAbstractReactiveElasticsearchTemplate
- Returns:
- the vendor name of the used cluster and client library
-
getRuntimeLibraryVersion
- Specified by:
getRuntimeLibraryVersion
in classAbstractReactiveElasticsearchTemplate
- Returns:
- the version of the used client runtime library.
-
getClusterVersion
- Specified by:
getClusterVersion
in classAbstractReactiveElasticsearchTemplate
-
update
public reactor.core.publisher.Mono<UpdateResponse> update(UpdateQuery updateQuery, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperations
Partial update of the document.- Parameters:
updateQuery
- query defining the updateindex
- the index where to update the records- Returns:
- a
Mono
emitting the update response
-
updateByQuery
public reactor.core.publisher.Mono<ByQueryResponse> updateByQuery(UpdateQuery updateQuery, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperations
Update document(s) by query.- Parameters:
updateQuery
- query defining the update, must not be nullindex
- the index where to update the records, must not be null- Returns:
- a
Mono
emitting the update response
-
execute
@Deprecated public <T> org.reactivestreams.Publisher<T> execute(ReactiveElasticsearchOperations.ClientCallback<org.reactivestreams.Publisher<T>> callback) Deprecated.Description copied from interface:ReactiveElasticsearchOperations
Execute within aReactiveElasticsearchOperations.ClientCallback
managing resources and translating errors.- Type Parameters:
T
- the type the Publisher emits- Parameters:
callback
- must not be null.- Returns:
- the
Publisher
emitting results.
-
executeWithIndicesClient
public <T> org.reactivestreams.Publisher<T> executeWithIndicesClient(ReactiveElasticsearchOperations.IndicesClientCallback<org.reactivestreams.Publisher<T>> callback) Description copied from interface:ReactiveElasticsearchOperations
Execute within aReactiveElasticsearchOperations.IndicesClientCallback
managing resources and translating errors.- Type Parameters:
T
- the type the Publisher emits- Parameters:
callback
- must not be null.- Returns:
- the
Publisher
emitting results.
-
executeWithClusterClient
public <T> org.reactivestreams.Publisher<T> executeWithClusterClient(ReactiveElasticsearchOperations.ClusterClientCallback<org.reactivestreams.Publisher<T>> callback) Description copied from interface:ReactiveElasticsearchOperations
Execute within aReactiveElasticsearchOperations.ClusterClientCallback
managing resources and translating errors.- Type Parameters:
T
- the type the Publisher emits- Parameters:
callback
- must not be null.- Returns:
- the
Publisher
emitting results.
-
indexOps
Description copied from interface:ReactiveElasticsearchOperations
Creates aReactiveIndexOperations
that is bound to the given index- Parameters:
index
- IndexCoordinates specifying the index- Returns:
- ReactiveIndexOperations implementation
-
indexOps
Description copied from interface:ReactiveElasticsearchOperations
Creates aReactiveIndexOperations
that is bound to the given class- Parameters:
clazz
- the entity clazz specifiying the index information- Returns:
- ReactiveIndexOperations implementation
-
cluster
Description copied from interface:ReactiveElasticsearchOperations
return aReactiveClusterOperations
instance that uses the same client communication setup as this ElasticsearchOperations instance.- Returns:
- ClusterOperations implementation
-
matchAllQuery
Description copied from interface:ReactiveSearchOperations
Creates aQuery
to find 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
-
idsQuery
Description copied from interface:ReactiveSearchOperations
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
-
execute
public <T> org.reactivestreams.Publisher<T> execute(org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchTemplate.ClientCallback<org.reactivestreams.Publisher<T>> callback) Execute a callback with theReactiveElasticsearchClient
and provide exception translation.- Type Parameters:
T
- the type returned from the callback- Parameters:
callback
- the callback to execute, must not be null- Returns:
- the callback result
-