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 Details

  • 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

      <T> reactor.core.publisher.Mono<T> save(T entity, IndexCoordinates index)
      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, see Flux.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 from
      bulkSize - 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 save
      index - 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 save
      index - the index to save to
      bulkSize - number of entities to put in a bulk request
      Returns:
      a Flux emitting the saved entities
      Since:
      5.1
    • saveAll

      default <T> reactor.core.publisher.Flux<T> saveAll(Iterable<T> entities, Class<T> clazz)
      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

      default <T> reactor.core.publisher.Flux<T> saveAll(Iterable<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. On errors returns with BulkFailureException 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

      <T> reactor.core.publisher.Flux<MultiGetItem<T>> multiGet(Query query, Class<T> clazz)
      Execute 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, used to determine the index
      Returns:
      flux with list of MultiGetItems 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 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
      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 with BulkFailureException 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 bulk
      bulkOptions - options to be added to the bulk request
      Throws:
      BulkFailureException - with information about the failed operation
      Since:
      4.0
    • get

      <T> reactor.core.publisher.Mono<T> get(String id, Class<T> entityType)
      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

      <T> reactor.core.publisher.Mono<T> get(String id, Class<T> entityType, IndexCoordinates index)
      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

      reactor.core.publisher.Mono<Boolean> exists(String id, Class<?> entityType)
      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

      reactor.core.publisher.Mono<Boolean> exists(String id, IndexCoordinates index)
      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

      reactor.core.publisher.Mono<String> delete(Object entity)
      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

      reactor.core.publisher.Mono<String> delete(Object entity, IndexCoordinates index)
      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

      reactor.core.publisher.Mono<String> delete(String id, IndexCoordinates index)
      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

      reactor.core.publisher.Mono<String> delete(String id, Class<?> entityType)
      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 reactor.core.publisher.Mono<ByQueryResponse> delete(Query query, Class<?> entityType)
      Deprecated.
      Delete the documents matching the given Query 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

      reactor.core.publisher.Mono<ByQueryResponse> delete(DeleteQuery query, Class<?> entityType)
      Delete the documents matching the given Query 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.
      Delete the documents matching the given Query 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 given Query 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

      reactor.core.publisher.Mono<UpdateResponse> update(UpdateQuery updateQuery, IndexCoordinates index)
      Partial update of the document.
      Parameters:
      updateQuery - query defining the update
      index - 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 null
      index - the index where to update the records, must not be null
      Returns:
      a Mono emitting the update response
      Since:
      4.2
    • reindex

      reactor.core.publisher.Mono<ReindexResponse> reindex(ReindexRequest reindexRequest)
      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

      reactor.core.publisher.Mono<String> submitReindex(ReindexRequest reindexRequest)
      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