Search code examples
javaelasticsearch-jest

Calling CreateIndex with settings without using ImmutableSettings


In the Jest readme there is an example of creating index with settings but it uses the ImmutableSettings class from ElasticSearch library.

Unfortunately due to some conflicts, we can't include ElasticSearch library in our project. Is there a way to use CreateIndex.Builder to create index with settings without using ImmutableSettings class from ElasticSearch library?

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());

Solution

  • See CreateIndexIntegrationTest which has live examples of both (with and without Elasticsearch builders) usage styles and please do read the README which explicitly recommends the integration tests for actual-use examples.