Update index dynamically doesn't work (Spring Data Elasticsearch)

折月煮酒 提交于 2019-12-24 18:18:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!