是否可以使用 spring 数据动态删除 Elasticsearch 上某个字段的索引?
Is It possible to dynamically remove indexing on a field on Elasticsearch using spring data?
我需要在构建索引时对 Elasticsearch 索引的所有字段进行索引,但一段时间后,如果需要,将 index
值更改为 false 并通过从某些字段中删除索引来提高性能.
当我在 @Field
中建立索引后设置 index = false
时,我搜索并阅读了 docs 并使用 spring 数据对其进行了测试,没有任何变化,并且字段仍可搜索。
@Document(indexName = "book")
@Setting(refreshInterval = "30s", shards = 3)
class Book(
@Id
@Field(type = FieldType.Keyword)
var id: String? = null,
@Field(type = FieldType.Keyword )
var title: String? = null,
@Field(type = FieldType.Keyword,index = false)
val isbn: String)
我想知道在使用 spring 数据建立索引后是否有另一种动态更改字段索引的解决方案?
您需要 运行 使用新索引名称修改程序以使用调整后的映射创建新索引,然后手动从旧索引重新索引到新索引:Elasticsearch documentation about reindexing.
我需要在构建索引时对 Elasticsearch 索引的所有字段进行索引,但一段时间后,如果需要,将 index
值更改为 false 并通过从某些字段中删除索引来提高性能.
当我在 @Field
中建立索引后设置 index = false
时,我搜索并阅读了 docs 并使用 spring 数据对其进行了测试,没有任何变化,并且字段仍可搜索。
@Document(indexName = "book")
@Setting(refreshInterval = "30s", shards = 3)
class Book(
@Id
@Field(type = FieldType.Keyword)
var id: String? = null,
@Field(type = FieldType.Keyword )
var title: String? = null,
@Field(type = FieldType.Keyword,index = false)
val isbn: String)
我想知道在使用 spring 数据建立索引后是否有另一种动态更改字段索引的解决方案?
您需要 运行 使用新索引名称修改程序以使用调整后的映射创建新索引,然后手动从旧索引重新索引到新索引:Elasticsearch documentation about reindexing.