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,- ReactiveScriptOperations,- ReactiveSqlOperations
Implementation of 
ReactiveElasticsearchOperations using the new
 Elasticsearch client.- Since:
- 4.4
- Author:
- Peter-Josef Meisch, Illia Ulianov, Junghoon Ban
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceReactiveElasticsearchTemplate.ClientCallback<T extends Publisher<?>>Callback interface to be used with} for operating directly oninvalid @link{@link #execute(ReactiveElasticsearchTemplate.ClientCallback<>)ReactiveElasticsearchClient.Nested classes/interfaces inherited from class org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplateAbstractReactiveElasticsearchTemplate.DocumentCallback<T>, AbstractReactiveElasticsearchTemplate.Entities<T>, AbstractReactiveElasticsearchTemplate.IndexResponseMetaData, AbstractReactiveElasticsearchTemplate.ReadDocumentCallback<T>, AbstractReactiveElasticsearchTemplate.ReadSearchDocumentCallback<T>, AbstractReactiveElasticsearchTemplate.SearchDocumentCallback<T>
- 
Field SummaryFields inherited from class org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplateconverter, entityCallbacks, entityOperations, mappingContext, refreshPolicy, routingResolverFields inherited from interface org.springframework.data.elasticsearch.core.ReactiveDocumentOperationsFLUX_SAVE_BULK_SIZE
- 
Constructor SummaryConstructorsConstructorDescriptionReactiveElasticsearchTemplate(ReactiveElasticsearchClient client, ElasticsearchConverter converter) 
- 
Method SummaryModifier and TypeMethodDescriptionFlux<? extends AggregationContainer<?>> aggregate(Query query, Class<?> entityType, IndexCoordinates index) Perform an aggregation specified by the givenquery.bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Bulk update all objects.closePointInTime(String pit) Closes a point in timecluster()return aReactiveClusterOperationsinstance that uses the same client communication setup as this ElasticsearchOperations instance.delete(DeleteQuery query, Class<?> entityType, IndexCoordinates index) Delete the documents matching the givenQueryextracting index from entity metadata.deleteScript(String name) Deletes the script with the given nameprotected ReactiveElasticsearchTemplatedoCopy()doCount(Query query, Class<?> entityType, IndexCoordinates index) doDeleteById(String id, @Nullable String routing, IndexCoordinates index) doExists(String id, IndexCoordinates index) protected Flux<SearchDocument> doFind(Query query, Class<?> clazz, IndexCoordinates index) protected <T> Mono<SearchDocumentResponse> doFindForResponse(Query query, Class<?> clazz, IndexCoordinates index) protected <T> Mono<Tuple2<T, AbstractReactiveElasticsearchTemplate.IndexResponseMetaData>> doIndex(T entity, IndexCoordinates index) <T> Publisher<T> execute(ReactiveElasticsearchTemplate.ClientCallback<Publisher<T>> callback) Execute a callback with theReactiveElasticsearchClientand provide exception translation.<T> Mono<T> get(String id, Class<T> entityType, IndexCoordinates index) Fetch the entity with given id.Gest the script with the given name.Creates aQueryto find get all documents with given ids.Creates aReactiveIndexOperationsthat is bound to the given classindexOps(IndexCoordinates index) Creates aReactiveIndexOperationsthat is bound to the given indexCreates aQueryto find all documents.<T> Flux<MultiGetItem<T>> multiGet(Query query, Class<T> clazz, IndexCoordinates index) Execute a multiGet against elasticsearch for the given ids.openPointInTime(IndexCoordinates index, Duration keepAlive, Boolean ignoreUnavailable) Opens a point in time (pit) in Elasticsearch.Stores the given script in the Elasticsearch cluster.queryBuilderWithIds(List<String> ids) Creates aBaseQueryBuilderthat has the given ids setto the parameter value.reindex(ReindexRequest reindexRequest) Copies documents from a source to a destination.<T> Flux<T> saveAll(Mono<? extends Collection<? extends T>> entitiesPublisher, IndexCoordinates index) Index entities in the given index.Execute the sqlqueryagainst elasticsearch and return result asSqlResponsesubmitReindex(ReindexRequest reindexRequest) Submits a reindex task.update(UpdateQuery updateQuery, IndexCoordinates index) Partial update of the document.updateByQuery(UpdateQuery updateQuery, IndexCoordinates index) Update document(s) by query.Methods inherited from class org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplateaggregate, count, count, delete, delete, delete, delete, delete, exists, exists, get, getElasticsearchConverter, getEntityRouting, getIndexCoordinatesFor, getIndexQuery, getPersistentEntityFor, getRefreshPolicy, logVersions, maybeCallbackAfterConvert, maybeCallbackAfterLoad, maybeCallbackAfterSave, maybeCallbackBeforeConvert, multiGet, save, save, save, save, saveAll, search, search, searchForHits, searchForHits, searchForPage, searchForPage, setApplicationContext, setEntityCallbacks, setRefreshPolicy, suggest, suggest, withRefreshPolicy, withRoutingMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.elasticsearch.core.ReactiveDocumentOperationsbulkUpdate, save, save, save, save, saveAll, saveAllMethods inherited from interface org.springframework.data.elasticsearch.core.ReactiveSearchOperationscount, openPointInTime, search, search, searchForHits, searchForHits, searchForPage, searchForPage
- 
Constructor Details- 
ReactiveElasticsearchTemplatepublic ReactiveElasticsearchTemplate(ReactiveElasticsearchClient client, ElasticsearchConverter converter) 
 
- 
- 
Method Details- 
doIndexprotected <T> Mono<Tuple2<T, AbstractReactiveElasticsearchTemplate.IndexResponseMetaData>> doIndex(T entity, IndexCoordinates index) - Specified by:
- doIndexin class- AbstractReactiveElasticsearchTemplate
 
- 
saveAllpublic <T> Flux<T> saveAll(Mono<? extends Collection<? extends T>> entitiesPublisher, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperationsIndex entities in the given index. If the index is null or empty the index name provided via entity metadata is used.- Type Parameters:
- T-
- Parameters:
- entitiesPublisher- must not be null.
- index- the target index, must not be null
- Returns:
- a Fluxemitting saved entities.
 
- 
doExists- Specified by:
- doExistsin class- AbstractReactiveElasticsearchTemplate
 
- 
deleteDescription copied from interface:ReactiveDocumentOperationsDelete the documents matching the givenQueryextracting 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 Monoemitting the number of the removed documents.
 
- 
getDescription copied from interface:ReactiveDocumentOperationsFetch the entity with given id.- Type Parameters:
- T-
- Parameters:
- id- must not be null.
- index- the target index, must not be null
- Returns:
- the Monoemitting the entity or signalling completion if none found.
 
- 
reindexDescription copied from interface:ReactiveDocumentOperationsCopies 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 Monoemitting the reindex response
 
- 
submitReindexDescription copied from interface:ReactiveDocumentOperationsSubmits a reindex task. (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)- Parameters:
- reindexRequest- reindex request parameters
- Returns:
- a Monoemitting the task id.
 
- 
updateDescription copied from interface:ReactiveDocumentOperationsPartial update of the document.- Parameters:
- updateQuery- query defining the update
- index- the index where to update the records
- Returns:
- a Monoemitting the update response
 
- 
updateByQueryDescription copied from interface:ReactiveDocumentOperationsUpdate document(s) by query.- Parameters:
- updateQuery- query defining the update, must not be null
- index- the index where to update the records, must not be null
- Returns:
- a Monoemitting the update response
 
- 
bulkUpdatepublic Mono<Void> bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Description copied from interface:ReactiveDocumentOperationsBulk update all objects. Will do update.- Parameters:
- queries- the queries to execute in bulk
- bulkOptions- options to be added to the bulk request
 
- 
doDeleteById- Specified by:
- doDeleteByIdin class- AbstractReactiveElasticsearchTemplate
 
- 
multiGetDescription copied from interface:ReactiveDocumentOperationsExecute a multiGet against elasticsearch for the given ids.- Parameters:
- query- the query defining the ids of the objects to get
- clazz- the type of the object to be returned
- index- the index(es) from which the objects are read.
- Returns:
- flux with list of MultiGetItems that contain the entities
- See Also:
 
- 
doCopy- Specified by:
- doCopyin class- AbstractReactiveElasticsearchTemplate
 
- 
doFind- Specified by:
- doFindin class- AbstractReactiveElasticsearchTemplate
 
- 
doCount- Specified by:
- doCountin class- AbstractReactiveElasticsearchTemplate
 
- 
doFindForResponseprotected <T> Mono<SearchDocumentResponse> doFindForResponse(Query query, Class<?> clazz, IndexCoordinates index) - Specified by:
- doFindForResponsein class- AbstractReactiveElasticsearchTemplate
 
- 
aggregatepublic Flux<? extends AggregationContainer<?>> aggregate(Query query, Class<?> entityType, IndexCoordinates index) Description copied from interface:ReactiveSearchOperationsPerform 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 Fluxemitting matching aggregations one by one.
 
- 
openPointInTimepublic Mono<String> openPointInTime(IndexCoordinates index, Duration keepAlive, Boolean ignoreUnavailable) Description copied from interface:ReactiveSearchOperationsOpens a point in time (pit) in Elasticsearch.- Specified by:
- openPointInTimein interface- ReactiveSearchOperations
- Overrides:
- openPointInTimein class- AbstractReactiveElasticsearchTemplate
- Parameters:
- index- the index name(s) to use
- keepAlive- the duration the pit shoult be kept alive
- ignoreUnavailable- if {$literal true} the call will fail if any of the indices is missing or closed
- Returns:
- the pit identifier
 
- 
closePointInTimeDescription copied from interface:ReactiveSearchOperationsCloses a point in time- Specified by:
- closePointInTimein interface- ReactiveSearchOperations
- Overrides:
- closePointInTimein class- AbstractReactiveElasticsearchTemplate
- Parameters:
- pit- the pit identifier as returned by- ReactiveSearchOperations.openPointInTime(IndexCoordinates, Duration, Boolean)
- Returns:
- true on success
 
- 
putScriptDescription copied from interface:ReactiveScriptOperationsStores the given script in the Elasticsearch cluster.- Specified by:
- putScriptin interface- ReactiveScriptOperations
- Overrides:
- putScriptin class- AbstractReactiveElasticsearchTemplate
- Returns:
- {true if successful
 
- 
getScriptDescription copied from interface:ReactiveScriptOperationsGest the script with the given name.- Specified by:
- getScriptin interface- ReactiveScriptOperations
- Overrides:
- getScriptin class- AbstractReactiveElasticsearchTemplate
- Parameters:
- name- the name of the script
- Returns:
- Script or null when a script with this name does not exist.
 
- 
deleteScriptDescription copied from interface:ReactiveScriptOperationsDeletes the script with the given name- Specified by:
- deleteScriptin interface- ReactiveScriptOperations
- Overrides:
- deleteScriptin class- AbstractReactiveElasticsearchTemplate
- Parameters:
- name- the name of the script.
- Returns:
- true if the request was acknowledged by the cluster.
 
- 
getVendor- Specified by:
- getVendorin class- AbstractReactiveElasticsearchTemplate
- Returns:
- the vendor name of the used cluster and client library
 
- 
getRuntimeLibraryVersion- Specified by:
- getRuntimeLibraryVersionin class- AbstractReactiveElasticsearchTemplate
- Returns:
- the version of the used client runtime library.
 
- 
getClusterVersion- Specified by:
- getClusterVersionin class- AbstractReactiveElasticsearchTemplate
 
- 
indexOpsDescription copied from interface:ReactiveElasticsearchOperationsCreates aReactiveIndexOperationsthat is bound to the given index- Parameters:
- index- IndexCoordinates specifying the index
- Returns:
- ReactiveIndexOperations implementation
 
- 
indexOpsDescription copied from interface:ReactiveElasticsearchOperationsCreates aReactiveIndexOperationsthat is bound to the given class- Parameters:
- clazz- the entity clazz specifiying the index information
- Returns:
- ReactiveIndexOperations implementation
 
- 
clusterDescription copied from interface:ReactiveElasticsearchOperationsreturn aReactiveClusterOperationsinstance that uses the same client communication setup as this ElasticsearchOperations instance.- Returns:
- ClusterOperations implementation
 
- 
matchAllQueryDescription copied from interface:ReactiveSearchOperationsCreates aQueryto 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
 
- 
idsQueryDescription copied from interface:ReactiveSearchOperationsCreates 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
 
- 
queryBuilderWithIdsDescription copied from interface:ReactiveSearchOperationsCreates aBaseQueryBuilderthat 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
 
- 
searchDescription copied from interface:ReactiveSqlOperationsExecute the sqlqueryagainst elasticsearch and return result asSqlResponse- Parameters:
- query- the query to execute
- Returns:
- SqlResponsecontaining the list of found objects
 
- 
executepublic <T> Publisher<T> execute(ReactiveElasticsearchTemplate.ClientCallback<Publisher<T>> callback) Execute a callback with theReactiveElasticsearchClientand 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
 
 
-