spel

How to provide a dynamic index name in Spring Data Elasticsearch using SpEL

In Spring Data Elasticsearch – at the time of writing, version 4.0 is the current version – the name of an index is normally defined by the @Document annotation on the entity class. For the following examples let’s assume we want to write some log entries to Elasticsearch with our application. We use the following entity: @Document(indexName = "log") public class LogEntity { @Id private String id = UUID.randomUUID().toString(); @Field(type = FieldType.