Is it possible avoid the indexName in document annotation? Because I have dynamic indexName so I cannot define it previously
1 Answer
According to this issue and the related PR, you can use a SpEL expression in the indexName attribute of the @Document annotation:
@Document(indexName = "#{@somePrefix}-index", type = "sometype")
where you also have a bean like the one below defined in your context
<bean id="somePrefix" class="java.lang.String">
<constructor-arg value="${env}-myapp"/>
</bean>
So in your case, you could have a bean which contains a mutable index name that is then used to create/search the new indices.
6 Comments
Carlos Vázquez Losada
So how can I modify the bean value from a Java method?
Val
May the bright mind who downvoted care to explain why so all the community benefits from his wisdom ;-)
Val
@CarlosVázquezLosada You probably should show some code so we better see what you're willing to achieve
Carlos Vázquez Losada
Yo @Val I have created a new question, because this one is not mine so I couldn't paste my own code.
Val
Here it is: stackoverflow.com/questions/48578688/…
|
update any of those dynamically created indices with info to Elasticsearchmean?