【问题标题】:How to update Index settings after index creation in spring-data-elasticsearch如何在 spring-data-elasticsearch 中创建索引后更新索引设置
【发布时间】:2021-05-11 21:54:12
【问题描述】:

我正在使用 spring-data-elasticsearch 编写 spring-boot 应用程序。我有一个在弹性搜索中自动创建索引的实体类。但我想定义一个分析器并将其设置为一个字段。

我期待像回调这样的东西来支持这一点。现在索引正在使用 @Document

创建
@Document(indexName = "products", shards = 1, versionType = VersionType.INTERNAL, createIndex = true)

【问题讨论】:

    标签: spring-boot spring-data-elasticsearch


    【解决方案1】:

    您可以禁用自动索引创建,并使用IndexOperations.create(Document settings) 方法自行创建索引。 Document

    或者您在类路径上的 json 文件中提供设置,并使用 @Setting 注释引用它。作为参考检查这个test code

    【讨论】:

    • 如果我们在createIndex=true模式下创建后修改设置怎么办?这些更改会反映在索引设置中吗?
    • Spring Data Elasticsearch 的IndexOperations 目前不支持更新索引设置。
    • 我认为手动创建索引总是更好
    猜你喜欢
    • 1970-01-01
    • 2017-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-26
    • 1970-01-01
    • 2021-07-02
    相关资源
    最近更新 更多