问题
I have a model which is:
@Document(indexName = "index", type = "logs")
public class Log {
@Id
private String id;
private String test_no;
private String entire_log;
private String method;
private String timestamp;
private String thread_name;
private String level;
private String logger_name;
private String formatted_message;
// CONSTRUCTORS, GETTERS AND SETTERS...
}
I have an applicationContext.xml
file which contains a bean, used to save the value of the dynamic index. The location of this file is inside of src/main/resources
directory, the same location than application.properties
file. The bean is:
<bean id="index" class="elastest.loganalyzer.es.client.model.Index">
<property name="v" value="defaut"></property>
</bean>
where the Index class is a simple class which contains a param "v":
public class Index {
String v;
public Index() {
this.v = "default";
}
public String getV() {
return v;
}
public void setV(String v) {
this.v = v;
}
}
What I want to do is to make the index of the above model (Log) dynamic. I have tried it by different ways but I can't find the correct solution:
@Document(indexName = "#{index}", type = "logs")
@Document(indexName = "#{index.v}", type = "logs")
@Document(indexName = "#{index.getV()}", type = "logs")
So... How can I make it works?
来源:https://stackoverflow.com/questions/48578688/update-index-dynamically-doesnt-work-spring-data-elasticsearch