提问者:小点点

Elasticsearch和Spring数据:如何使用别名重新索引


我有一个这样注释的bean:

@Document(indexName = "foo", type = "bar")
public class BarEntity {
    private String someField = "";
}

“foo”是elasticsearch中foo-2016-11-04的别名:

"foo-2016.11.04" : {
  "aliases" : {
    "foo" : { }
  }
}

我想做的是将某个字段的索引更改为not_analyzed:

@Document(indexName = "foo", type = "bar")
public class BarEntity {
    @Field(index = FieldIndex.not_analyzed, type = FieldType.String)
    private String someField = "";
}

据我所知,我必须创建一个新的索引并将别名指向该索引,例如foo-2016.11.29。

我如何在带有Spring Data的elasticeseach 2.3中做到这一点?我的bean链接到别名,我猜Spring Data会自动创建正确的索引。我只是不知道如何让它通过别名创建索引。

我是先将foo-2016.11.04重新索引到foo-2016.11.29,更新别名以指向新的,然后重新部署Spring应用程序,还是这里还有其他事情要做?


共1个答案

匿名用户

您不能通过别名创建索引,但您可以显式创建带时间戳的索引并使用索引模板自动将其分配给别名。

https://www.elastic.co/guide/en/elasticsearch/reference/2.3/indices-templates.html