在不使用 ImmutableSettings 的情况下使用设置调用 CreateIndex
Calling CreateIndex with settings without using ImmutableSettings
在 Jest 自述文件中有一个使用设置创建索引的示例,但它使用 ElasticSearch 库中的 ImmutableSettings
class。
不幸的是,由于一些冲突,我们不能在我们的项目中包含 ElasticSearch 库。有没有一种方法可以使用 CreateIndex.Builder 创建带有设置的索引,而无需使用 ElasticSearch 库中的 ImmutableSettings
class?
String settings = "\"settings\" : {\n" +
" \"number_of_shards\" : 5,\n" +
" \"number_of_replicas\" : 1\n" +
" }\n";
client.execute(new CreateIndex.Builder("articles").settings(ImmutableSettings.builder().loadFromSource(settings).build().getAsMap()).build());
参见 CreateIndexIntegrationTest which has live examples of both (with and without Elasticsearch builders) usage styles and please do read the README,其中明确推荐了实际使用示例的集成测试。
在 Jest 自述文件中有一个使用设置创建索引的示例,但它使用 ElasticSearch 库中的 ImmutableSettings
class。
不幸的是,由于一些冲突,我们不能在我们的项目中包含 ElasticSearch 库。有没有一种方法可以使用 CreateIndex.Builder 创建带有设置的索引,而无需使用 ElasticSearch 库中的 ImmutableSettings
class?
String settings = "\"settings\" : {\n" +
" \"number_of_shards\" : 5,\n" +
" \"number_of_replicas\" : 1\n" +
" }\n";
client.execute(new CreateIndex.Builder("articles").settings(ImmutableSettings.builder().loadFromSource(settings).build().getAsMap()).build());
参见 CreateIndexIntegrationTest which has live examples of both (with and without Elasticsearch builders) usage styles and please do read the README,其中明确推荐了实际使用示例的集成测试。