在 spring boot / spring data elasticsearch 中禁用自动索引创建

Disable automatic index creation in spring boot / spring data elasticsearch

我想将创建索引(包括设置和映射)的过程与应用程序的其余部分分开,以便更好地控制我的应用程序的行为。 我的 spring 引导项目在启动时自动创建索引。有没有办法禁用自动索引创建过程?

@Document 注释具有 createIndex 属性,默认设置为 true。只需将其设置为:

@Document(indexName = "products", createIndex = false)