Page tree
Skip to end of metadata
Go to start of metadata

CAST supports Elasticsearch via its NoSQL for Java extension. Details about the support provided for Java with Spring Data source code is discussed below.

Supported Client Libraries

LibraryVersionSupported
spring-data-elasticsearchUp to: 4.2.3(tick)
spring-data-jestUp to: 3.3.1(tick)

Supported Operations

Operation

Methods Supported

Insert
 Insert operations
  • 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.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.core.ReactiveElasticsearchTemplate.saveAll
  • org.springframework.data.elasticsearch.core.ReactiveDocumentOperations.saveAll
  • org.springframework.data.elasticsearch.core.IndexOperations.create
  • org.springframework.data.elasticsearch.core.IndexOperations.putMapping
  • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareIndex
  • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.putMapping

Select
 Select operations
  • 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.PagingAndSortingRepository.findAll
  • 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.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.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.findAll
  • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.existsById
  • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.count
  • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.findById
  • org.springframework.data.elasticsearch.repository.support.SimpleReactiveElasticsearchRepository.findAllById
  • 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.ReactiveSortingRepository.findAll
  • 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
Update
 Update operations
  • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.bulkUpdate
  • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.prepareUpdate
  • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.update
Delete
 Delete operations
  • 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.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.delete
  • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.deleteById
  • org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.deleteAll
  • 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.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.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.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
  • com.github.vanroy.springdata.jest.JestElasticsearchTemplate.delete

Objects

Icon Description

Java Elasticsearch Cluster

Java Elasticsearch Index

Java Unknown Elasticsearch Cluster

Java Unknown Elasticsearch Index

Links

Links are created for transaction and function point needs:

Link typeSource and destination of link Methods supported
parentLink

Between Elasticsearch Cluster object and Elasticsearch Index object







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?

Once the analysis/snapshot generation is completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.

Cluster and Index Creation

 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())));

     }
}

cluster
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;
	}
}
index
@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

 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);
            });


 Insert Operation
Insert
public Book save(Book book) {
        return bookRepository.save(book);
    }

Delete Operation

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

Select Operation

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

Query Methods

 Query Methods
book repo
public interface BookRepository extends ElasticsearchRepository<Book, String> {

    Page<Book> findByAuthor(String author, Pageable pageable);

    List<Book> findByTitle(String title);

}
query method
public Page<Book> findByAuthor(String author, PageRequest pageRequest) {
        return bookRepository.findByAuthor(author, pageRequest);
    }

Elasticsearch Operations / Elasticsearch Template

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

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.
  • No labels