Interface ReactiveDocumentOperations
- All Known Subinterfaces:
ReactiveElasticsearchOperations
- All Known Implementing Classes:
AbstractReactiveElasticsearchTemplate
,ReactiveElasticsearchTemplate
public interface ReactiveDocumentOperations
The reactive operations for the
Elasticsearch Document APIs.
- Since:
- 4.0
- Author:
- Peter-Josef Meisch, Aleksei Arsenev, Roman Puchkovskiy, Farid Faoudi, Sijia Liu
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault reactor.core.publisher.Mono<Void>
bulkUpdate
(List<UpdateQuery> queries, IndexCoordinates index) Bulk update all objects.reactor.core.publisher.Mono<Void>
bulkUpdate
(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Bulk update all objects.reactor.core.publisher.Mono<String>
Delete the given entity extracting index from entity metadata.reactor.core.publisher.Mono<String>
delete
(Object entity, IndexCoordinates index) Delete the given entity extracting index from entity metadata.reactor.core.publisher.Mono<String>
Delete the entity with given id extracting index from entity metadata.reactor.core.publisher.Mono<String>
delete
(String id, IndexCoordinates index) Delete the entity with given id.reactor.core.publisher.Mono<ByQueryResponse>
delete
(DeleteQuery query, Class<?> entityType) Delete the documents matching the givenQuery
extracting index from entity metadata.reactor.core.publisher.Mono<ByQueryResponse>
delete
(DeleteQuery query, Class<?> entityType, IndexCoordinates index) Delete the documents matching the givenQuery
extracting index from entity metadata.reactor.core.publisher.Mono<ByQueryResponse>
Deprecated.reactor.core.publisher.Mono<ByQueryResponse>
delete
(Query query, Class<?> entityType, IndexCoordinates index) Deprecated.since 5.3.0, usedelete(DeleteQuery, Class, IndexCoordinates)
reactor.core.publisher.Mono<Boolean>
Check if an entity with given id exists.reactor.core.publisher.Mono<Boolean>
exists
(String id, IndexCoordinates index) Check if an entity with given id exists.<T> reactor.core.publisher.Mono<T>
Find the document with the given id mapped onto the given entityType.<T> reactor.core.publisher.Mono<T>
get
(String id, Class<T> entityType, IndexCoordinates index) Fetch the entity with given id.<T> reactor.core.publisher.Flux<MultiGetItem<T>>
Execute a multiGet against elasticsearch for the given ids.<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.default <T> reactor.core.publisher.Flux<T>
Indexes the entities into the index extracted from entity metadata.<T> reactor.core.publisher.Flux<T>
Indexes the entities into the index extracted from entity metadata.default <T> reactor.core.publisher.Flux<T>
save
(reactor.core.publisher.Flux<T> entities, IndexCoordinates index) Indexes the entities into the given index.<T> reactor.core.publisher.Flux<T>
save
(reactor.core.publisher.Flux<T> entities, IndexCoordinates index, int bulkSize) Indexes the entities into the given index.default <T> reactor.core.publisher.Mono<T>
save
(reactor.core.publisher.Mono<? extends T> entityPublisher) Index the given entity, once available, extracting index from entity metadata.default <T> reactor.core.publisher.Mono<T>
save
(reactor.core.publisher.Mono<? extends T> entityPublisher, IndexCoordinates index) Index the entity, once available, under the given type in the given index.<T> reactor.core.publisher.Mono<T>
save
(T entity) Index the given entity extracting index from entity metadata.<T> reactor.core.publisher.Mono<T>
save
(T entity, IndexCoordinates index) Index the entity under the given type in the given index.default <T> reactor.core.publisher.Flux<T>
Index entities the index extracted from entity metadata.default <T> reactor.core.publisher.Flux<T>
saveAll
(Iterable<T> entities, IndexCoordinates index) Index entities in the given index.<T> reactor.core.publisher.Flux<T>
saveAll
(reactor.core.publisher.Mono<? extends Collection<? extends T>> entities, Class<T> clazz) Index entities in the index extracted from entity metadata.<T> reactor.core.publisher.Flux<T>
saveAll
(reactor.core.publisher.Mono<? extends Collection<? extends T>> entities, 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.
-
Field Details
-
FLUX_SAVE_BULK_SIZE
static final int FLUX_SAVE_BULK_SIZE- See Also:
-
-
Method Details
-
save
default <T> reactor.core.publisher.Mono<T> save(reactor.core.publisher.Mono<? extends T> entityPublisher) Index the given entity, once available, extracting index from entity metadata.- Type Parameters:
T
-- Parameters:
entityPublisher
- must not be null.- Returns:
- a
Mono
emitting the saved entity.
-
save
default <T> reactor.core.publisher.Mono<T> save(reactor.core.publisher.Mono<? extends T> entityPublisher, IndexCoordinates index) Index the entity, once available, under the given type in the given index. If the index is null or empty the index name provided via entity metadata is used. Same for the type.- Type Parameters:
T
-- Parameters:
entityPublisher
- must not be null.index
- the target index, must not be null- Returns:
- a
Mono
emitting the saved entity.
-
save
<T> reactor.core.publisher.Mono<T> save(T entity) Index the given entity extracting index from entity metadata.- Type Parameters:
T
-- Parameters:
entity
- must not be null.- Returns:
- a
Mono
emitting the saved entity.
-
save
Index the entity under the given type in the given index. If the index is null or empty the index name provided via entity metadata is used. Same for the type.- Type Parameters:
T
-- Parameters:
entity
- must not be null.index
- the target index, must not be null- Returns:
- a
Mono
emitting the saved entity.
-
save
default <T> reactor.core.publisher.Flux<T> save(reactor.core.publisher.Flux<T> entities, Class<?> clazz) Indexes the entities into the index extracted from entity metadata.- Type Parameters:
T
- entity type- Parameters:
entities
-clazz
- the class to get the index name from- Returns:
- a Flux emitting the saved entities
- Since:
- 5.1
-
save
<T> reactor.core.publisher.Flux<T> save(reactor.core.publisher.Flux<T> entities, Class<?> clazz, int bulkSize) Indexes the entities into the index extracted from entity metadata. The entities are collected into batches of {bulkSize} with a maximal timeout of 200 ms, seeFlux.bufferTimeout(int, java.time.Duration)
and then sent in a bulk operation to Elasticsearch.- Type Parameters:
T
- entity type- Parameters:
entities
-clazz
- the class to get the index name frombulkSize
- number of entities to put in a bulk request- Returns:
- a Flux emitting the saved entities
- Since:
- 5.1
-
save
default <T> reactor.core.publisher.Flux<T> save(reactor.core.publisher.Flux<T> entities, IndexCoordinates index) Indexes the entities into the given index.- Type Parameters:
T
- entity type- Parameters:
entities
- the entities to saveindex
- the index to save to- Returns:
- a Flux emitting the saved entities
- Since:
- 5.1
-
save
<T> reactor.core.publisher.Flux<T> save(reactor.core.publisher.Flux<T> entities, IndexCoordinates index, int bulkSize) Indexes the entities into the given index. The entities are collected into batches of {bulkSize} with a maximal timeout of 200 ms, see {@link reactor.core.publisher.Flux#bufferTimeout(int, java.time * .Duration)} and then sent in a bulk operation to Elasticsearch.- Type Parameters:
T
- entity type- Parameters:
entities
- the entities to saveindex
- the index to save tobulkSize
- number of entities to put in a bulk request- Returns:
- a Flux emitting the saved entities
- Since:
- 5.1
-
saveAll
Index entities the index extracted from entity metadata.- Parameters:
entities
- must not be null.clazz
- the entity class, used to determine the index- Returns:
- a
Flux
emitting saved entities. - Since:
- 4.1
-
saveAll
Index entities in the given index. If the index is null or empty the index name provided via entity metadata is used. On errors returns withBulkFailureException
with information about the failed operation- Type Parameters:
T
-- Parameters:
entities
- must not be null.index
- the target index, must not be null- Returns:
- a
Flux
emitting saved entities. - Since:
- 4.0
-
saveAll
<T> reactor.core.publisher.Flux<T> saveAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> entities, Class<T> clazz) Index entities in the index extracted from entity metadata.- Parameters:
entities
- must not be null.clazz
- the entity class, used to determine the index- Returns:
- a
Flux
emitting saved entities. - Since:
- 4.1
-
saveAll
<T> reactor.core.publisher.Flux<T> saveAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> entities, IndexCoordinates index) Index 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:
entities
- must not be null.index
- the target index, must not be null- Returns:
- a
Flux
emitting saved entities. - Since:
- 4.0
-
multiGet
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 returned, used to determine the index- Returns:
- flux with list of
MultiGetItem
s that contain the entities - Since:
- 4.1
- See Also:
-
multiGet
<T> reactor.core.publisher.Flux<MultiGetItem<T>> multiGet(Query query, Class<T> clazz, IndexCoordinates index) 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 - Since:
- 4.0
- See Also:
-
bulkUpdate
default reactor.core.publisher.Mono<Void> bulkUpdate(List<UpdateQuery> queries, IndexCoordinates index) Bulk update all objects. Will do update. On errors returns withBulkFailureException
with information about the failed operation- Parameters:
queries
- the queries to execute in bulk- Since:
- 4.0
-
bulkUpdate
reactor.core.publisher.Mono<Void> bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Bulk update all objects. Will do update.- Parameters:
queries
- the queries to execute in bulkbulkOptions
- options to be added to the bulk request- Throws:
BulkFailureException
- with information about the failed operation- Since:
- 4.0
-
get
Find the document with the given id mapped onto the given entityType.- Type Parameters:
T
-- Parameters:
id
- the _id of the document to fetch.entityType
- the domain type used for mapping the document.- Returns:
Mono.empty()
if not found.- Since:
- 4.0
-
get
Fetch the entity with given id.- Type Parameters:
T
-- 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.
-
exists
Check if an entity with given id exists.- Parameters:
id
- the _id of the document to look for.entityType
- the domain type used.- Returns:
- a
Mono
emitting true if a matching document exists, false otherwise.
-
exists
Check if an entity with given id exists.- Parameters:
id
- the _id of the document to look for.index
- the target index, must not be null- Returns:
- a
Mono
emitting true if a matching document exists, false otherwise.
-
delete
Delete the given entity extracting index from entity metadata.- Parameters:
entity
- must not be null.- Returns:
- a
Mono
emitting the id of the removed document.
-
delete
Delete the given entity extracting index from entity metadata.- Parameters:
entity
- must not be null.index
- the target index, must not be null- Returns:
- a
Mono
emitting the id of the removed document.
-
delete
Delete the entity with given id.- Parameters:
id
- must not be null.index
- the target index, must not be null- Returns:
- a
Mono
emitting the id of the removed document.
-
delete
Delete the entity with given id extracting index from entity metadata.- Parameters:
id
- must not be null.entityType
- must not be null.- Returns:
- a
Mono
emitting the id of the removed document. - Since:
- 4.0
-
delete
Deprecated.since 5.3.0, usedelete(DeleteQuery, Class)
Delete the documents matching the givenQuery
extracting index from entity metadata.- Parameters:
query
- must not be null.entityType
- must not be null.- Returns:
- a
Mono
emitting the number of the removed documents.
-
delete
Delete the documents matching the givenQuery
extracting index from entity metadata.- Parameters:
query
- must not be null.entityType
- must not be null.- Returns:
- a
Mono
emitting the number of the removed documents. - Since:
- 5.3
-
delete
@Deprecated reactor.core.publisher.Mono<ByQueryResponse> delete(Query query, Class<?> entityType, IndexCoordinates index) Deprecated.since 5.3.0, usedelete(DeleteQuery, Class, IndexCoordinates)
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.
-
delete
reactor.core.publisher.Mono<ByQueryResponse> delete(DeleteQuery query, Class<?> entityType, IndexCoordinates index) 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. - Since:
- 5.3
-
update
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 - Since:
- 4.1
-
updateByQuery
reactor.core.publisher.Mono<ByQueryResponse> updateByQuery(UpdateQuery updateQuery, IndexCoordinates index) 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 - Since:
- 4.2
-
reindex
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 - Since:
- 4.4
-
submitReindex
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. - Since:
- 4.4
-
delete(DeleteQuery, Class)