3

I'm using this annotation provided by spring-starter-elastic-searchto create a document and I would like to inject the parameter indexname dynamically:

@Entity
@Document(indexName = "myindex")
public class StockQuotation 

In another bean I have successfully done that by using @Valueon a field:

@Value("${elasticsearch.index.name}")
public String indexName;

However, I have tried to inject it in the same way in the annotation and the translation is not done:

@Entity
@Document(indexName = "${elasticsearch.index.name}")
public class StockQuotation

As I get this exception:

Caused by: org.elasticsearch.indices.IndexMissingException: [${elasticsearch.index.name}] missing

What would be the appropriate approach to do this?

Thanks

Victor
  • 2,450
  • 2
  • 23
  • 54
  • Resolved in this post : http://stackoverflow.com/questions/33069670/spring-data-elasticsearch-document-indexname-defined-at-runtime. Hope it could helps. – sluk3r Mar 25 '17 at 08:14

0 Answers0