Reactive Elasticsearch Operations

ReactiveElasticsearchOperations is the gateway to executing high level commands against an Elasticsearch cluster using the ReactiveElasticsearchClient.

The ReactiveElasticsearchTemplate is the default implementation of ReactiveElasticsearchOperations.

To get started the ReactiveElasticsearchOperations needs to know about the actual client to work with. Please see Reactive Rest Client for details on the client and how to configure it.

Reactive Operations Usage

ReactiveElasticsearchOperations lets you save, find and delete your domain objects and map those objects to documents stored in Elasticsearch.

Consider the following:

Example 1. Use the ReactiveElasticsearchOperations
@Document(indexName = "marvel")
public class Person {

  private @Id String id;
  private String name;
  private int age;
  // Getter/Setter omitted...
ReactiveElasticsearchOperations operations;

// ... Person("Bruce Banner", 42))                    (1)
  .flatMap(person -> operations.get(, Person.class))      (2)
  .flatMap(person -> operations.delete(person))                    (3)
  .flatMap(id -> operations.count(Person.class))                   (4)
  .subscribe();                                                    (5)

The above outputs the following sequence on the console.

> Person(id=QjWCWWcBXiLAnp77ksfR, name=Bruce Banner, age=42)
> Person(id=QjWCWWcBXiLAnp77ksfR, name=Bruce Banner, age=42)
> QjWCWWcBXiLAnp77ksfR
> 0
1 Insert a new Person document into the marvel index . The id is generated on server side and set into the instance returned.
2 Lookup the Person with matching id in the marvel index.
3 Delete the Person with matching id, extracted from the given instance, in the marvel index.
4 Count the total number of documents in the marvel index.
5 Don’t forget to subscribe().