Support of Elasticsearch for Spring Data

CAST supports Elasticsearch via its com.castsoftware.nosqljavaexternal link extension. Details about how this support is provided for Java with Spring Data source code is discussed below.

Supported Client Libraries

Library Version Supported
spring-data-elasticsearchexternal link Up to: 5.4.2
spring-data-jestexternal link Up to: 3.3.1

Supported Operations

  • Operation
  • Methods Supported
  • Insert
    com.github.vanroy.springdata.jest.JestElasticsearchTemplate
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareIndex
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.putMapping
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.createIndex
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.createIndexIfNotCreated
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.createIndexWithSettings
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareIndex
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.putMapping
    org.springframework.data.elasticsearch.core
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.saveAll
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.saveAll
    • org.springframework.data.elasticsearch.core.IndexOperations.create
    • org.springframework.data.elasticsearch.core.IndexOperations.putMapping
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.save
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.save
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.save
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.save
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.saveAll
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.saveAll
    • org.springframework.data.elasticsearch.core.ReactiveIndexOperations.create
    • org.springframework.data.elasticsearch.core.ReactiveIndexOperations.putMapping
    org.springframework.data.repository
    • org.springframework.data.repository.CrudRepository.save
    • org.springframework.data.repository.CrudRepository.saveAll
    • org.springframework.data.repository.ElasticsearchRepository.save
    • org.springframework.data.repository.ElasticsearchRepository.saveAll
    org.springframework.data.elasticsearch.repository.support
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.save
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.saveAll
    • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.save
    • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.saveAll
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchIndicesClient.create
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices.createIndex
    Select
    org.springframework.data.repository.CrudRepository
    • org.springframework.data.repository.CrudRepository.existsById
    • org.springframework.data.repository.CrudRepository.findAll
    • org.springframework.data.repository.CrudRepository.findById
    • org.springframework.data.repository.CrudRepository.findAllById
    • org.springframework.data.repository.CrudRepository.count
    org.springframework.data.repository.ElasticsearchRepository
    • org.springframework.data.repository.ElasticsearchRepository.existsById
    • org.springframework.data.repository.ElasticsearchRepository.findAll
    • org.springframework.data.repository.ElasticsearchRepository.findById
    • org.springframework.data.repository.ElasticsearchRepository.findAllById
    • org.springframework.data.repository.ElasticsearchRepository.count
    • org.springframework.data.repository.ElasticsearchRepository.searchSimilar
    org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.findAll
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.existsById
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.count
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.findById
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.findAllById
    org.springframework.data.repository.reactive.ReactiveCrudRepository
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.count
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.existsById
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.findAll
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.findAllById
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.findById
    org.springframework.data.repository.reactive.ReactiveElasticsearchRepository
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.count
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.existsById
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.findAll
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.findAllById
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.findById
    org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.count
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.exists
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.get
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.multiGet
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.multiSearch
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.search
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.searchForStream
    org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.count
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.exists
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.get
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.multiGet
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.multiSearch
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.search
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.searchForStream
    org.springframework.data.elasticsearch.core.SearchOperations
    • org.springframework.data.elasticsearch.core.SearchOperations.count
    • org.springframework.data.elasticsearch.core.SearchOperations.multiSearch
    • org.springframework.data.elasticsearch.core.SearchOperations.search
    • org.springframework.data.elasticsearch.core.SearchOperations.searchForStream
    • org.springframework.data.elasticsearch.core.SearchOperations.searchOne
    org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.count
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.exists
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.get
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.search
    org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.count
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.exists
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.get
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.search
    org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.count
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.findById
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.exists
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.find
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.searchOne
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.search
    com.github.vanroy.springdata.jest.JestElasticsearchTemplate
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.getMapping
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.getMultiResponse
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.getPersistentEntityFor
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.getSetting
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.indexExists
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.multiGet
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareScroll
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareQuery
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareSearch
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.query
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.queryForAlias
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.queryForIds
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.queryForList
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.queryForObject
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.queryForPage
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.refresh
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.retrieveIndexNameFromPersistentEntity
    org.springframework.data.elasticsearch.core.ElasticsearchTemplate
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.indexOps
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.count
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.get
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.multiGet
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.search
    org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.indexOps
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.getIndexCoordinatesFor
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.search
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.count
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.aggregate
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.exists
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.get
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.multiGet
    org.springframework.data.elasticsearch.core
    • org.springframework.data.elasticsearch.core.ReactiveSearchOperations.count
    • org.springframework.data.elasticsearch.core.ReactiveSearchOperations.search
    • org.springframework.data.elasticsearch.core.ReactiveSearchOperations.searchForHits
    • org.springframework.data.elasticsearch.core.ReactiveSearchOperations.searchForPage
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.exists
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.get
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.multiget
    • org.springframework.data.elasticsearch.core.ElasticsearchOperations.indexOps
    • org.springframework.data.elasticsearch.core.ElasticsearchOperations.getIndexCoordinatesFor
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.indexOps
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.getIndexCoordinatesFor
    • org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.indexOps
    • org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.count
    • org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.get
    • org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.multiGet
    • org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.search
    • org.springframework.data.elasticsearch.core.DocumentOperations.exists
    • org.springframework.data.elasticsearch.core.DocumentOperations.get
    • org.springframework.data.elasticsearch.core.DocumentOperations.multiGet
    • org.springframework.data.elasticsearch.core.ReactiveIndexOperations.exists
    • org.springframework.data.elasticsearch.core.ReactiveIndexOperations.refresh
    • org.springframework.data.elasticsearch.core.ReactiveIndexOperations.getMapping
    org.springframework.data.elasticsearch.client
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchIndicesClient.exists
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchIndicesClient.get
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchIndicesClient.refresh
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices.existsIndex
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices.refreshIndex
    • org.springframework.data.repository.PagingAndSortingRepository.findAll
    • org.springframework.data.repository.reactive.ReactiveSortingRepository.findAll
    Update
    com.github.vanroy.springdata.jest.JestElasticsearchTemplate
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.bulkUpdate
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareUpdate
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.update
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.bulkIndex
    org.springframework.data.elasticsearch.client
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.bulk
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.index
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.update
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.bulk
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.index
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.update
    org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.bulkUpdate
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.bulkIndex
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.index
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.update
    org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.bulkUpdate
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.bulkIndex
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.index
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.update
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.update
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.updateByQuery
    • org.springframework.data.elasticsearch.core.DocumentOperations.bulkIndex
    • org.springframework.data.elasticsearch.core.DocumentOperations.bulkUpdate
    Delete
    org.springframework.data.repository.CrudRepository
    • org.springframework.data.repository.CrudRepository.delete
    • org.springframework.data.repository.CrudRepository.deleteById
    • org.springframework.data.repository.CrudRepository.deleteAllById
    • org.springframework.data.repository.CrudRepository.deleteAll
    org.springframework.data.repository.ElasticsearchRepositoryy
    • org.springframework.data.repository.ElasticsearchRepository.delete
    • org.springframework.data.repository.ElasticsearchRepository.deleteById
    • org.springframework.data.repository.ElasticsearchRepository.deleteAllById
    • org.springframework.data.repository.ElasticsearchRepository.deleteAll
    org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.delete
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.deleteById
    • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.deleteAll
    org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository
    • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.delete
    • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.deleteById
    • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.deleteAll
    org.springframework.data.repository.reactive.ReactiveCrudRepository
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.delete
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.deleteAll
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.deleteById
    • org.springframework.data.repository.reactive.ReactiveCrudRepository.deleteAllById
    org.springframework.data.repository.reactive.ReactiveElasticsearchRepository
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.delete
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.deleteAll
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.deleteById
    • org.springframework.data.repository.reactive.ReactiveElasticsearchRepository.deleteAllById
    org.springframework.data.elasticsearch.core
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.delete
    • org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.delete
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.delete
    • org.springframework.data.elasticsearch.core.DocumentOperations.delete
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.delete
    • org.springframework.data.elasticsearch.core.IndexOperations.delete
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.deleteIndex
    • org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.delete
    • org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate.delete
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.delete
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.deleteById
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations.deleteBy
    • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.delete
    • org.springframework.data.elasticsearch.core.ElasticsearchTemplate.delete
    • org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.delete
    • org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate.delete
    • org.springframework.data.elasticsearch.core.DocumentOperations.delete
    • org.springframework.data.elasticsearch.core.ReactiveIndexOperations.delete
    org.springframework.data.elasticsearch.client
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.delete
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient.deleteByQuery
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.delete
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.deleteByQuery
    • org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchIndicesClient.delete
    • org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices.deleteIndex
    • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.delete

    Objects

    Icon  Description
  • Java Elasticsearch Cluster
  • Java Elasticsearch Index
  • Java Unknown Elasticsearch Cluster
  • Java Unknown Elasticsearch Index

    All links are created between Elasticsearch Cluster object and Elasticsearch Index objects:

    Link type  Methods supported
    parentLink -
    useDeleteLink
  • delete
  • deleteAll
  • deleteById
  • deleteAllById
  • useInsertLink
  • save
  • saveAll
  • useSelectLink
  • findAllById
  • findAll
  • findById
  • count
  • existsById
  • searchSimilar
  • indexOps
  • get
  • multiGet
  • search
  • useUpdateLink
  • bulkUpdate
  • What results can you expect?

    Some example scenarios are shown below:

    Cluster and Index Creation

    public class EsConfig {
    
    
        @Autowired
        private EsSinkProperties properties;
    
    
        @Bean
        public Client client() throws Exception {
    
            Settings esSettings = Settings.builder()
                    .put("cluster.name", properties.getClusterName())
                    .build();
    
            TransportClient client = new PreBuiltTransportClient(esSettings)
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(properties.getHost()), Integer.parseInt(properties.getPort())));
    
         }
    }
    
    public class EsSinkProperties {
    
        /
         * Elasticsearch cluster name.
         */
        private String clusterName = "elasticsearch";
    
        /
         * Elasticsearch host name.
         */
        private String host = "localhost";
    
        /
         * Elasticsearch native port.
         */
        private String port = "9300";
    
        @NotBlank
        public String getClusterName() {
            return clusterName;
        }
    
        public void setClusterName(String clusterName) {
            this.clusterName = clusterName;
        }
    }
    
    @Document(indexName = "trader", type = "trade")
    public class Trade {
    
        @Id
        private String id;
    
        public String getId() {
            return id;
        }
    
        public void setId(String id) {
            this.id = id;
        }
    

    Insert Operation

    public override void Configure(EntityTypeBuilder<Contractor> builder)
            {
                builder.ToTable("Trial");
                builder.OwnsOne(m => m.Name, a =>
                {
                    a.Property(p => p.FirstName).HasMaxLength(300)
                        .HasColumnName("FirstName")
                        .HasDefaultValue("");
                    a.Property(p => p.LastName).HasMaxLength(300)
                        .HasColumnName("LastName")
                        .HasDefaultValue("");
                    a.Ignore(p => p.FullName);
                });
    
    public Book save(Book book) {
            return bookRepository.save(book);
        }
    

    Delete Operation

    public void delete(Book book) {
            bookRepository.delete(book);
        }
    

    Select Operation

    public Iterable<Book> findAll() {
            return bookRepository.findAll();
        }
    

    Query Methods

    public interface BookRepository extends ElasticsearchRepository<Book, String> {
    
        Page<Book> findByAuthor(String author, Pageable pageable);
    
        List<Book> findByTitle(String title);
    
    }
    
    public Page<Book> findByAuthor(String author, PageRequest pageRequest) {
            return bookRepository.findByAuthor(author, pageRequest);
        }
    

    Elasticsearch Operations / Elasticsearch Template

    public void deleteIndex() {
            operations.indexOps(Conference.class).delete();
    }
    

    ReactiveElasticsearchClient

    import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient;
    
    @Repository
    public class ElasticRepository {
    
        public static final String COURSE_INDEX = "course-store";
        private final ReactiveElasticsearchClient client;
        private final ObjectMapper objectMapper;
    
        public ElasticRepository(ReactiveElasticsearchClient client, ObjectMapper objectMapper) {
            this.client = client;
            this.objectMapper = objectMapper;
        }
    
        public Mono<DeleteResponse> deleteCourse() {
            return client.delete(deleteRequest -> deleteRequest.index(COURSE_INDEX));
        }
    }
    

    Known Limitations

    • Index is created as unknown, if the name is not retrieved from the properties file or if the name could not be resolved.
    • Limited support for Spring Data Elasticsearch 3.x
      • In 3.x, CRUD operations performed using ElasticsearchRepository are supported
      • In 3.x no support for CRUD operations performed using ElasticsearchTemplate. However, if the user configures version 3.x jars inside its class path, then ElasticsearchTemplate will produce links.