1
votes

I am new to JEST technology. I am practicing it from https://github.com/searchbox-io/Jest/tree/master/jest#authentication link. I am able to create index and adding documents to it, but I want to to pass multiple nodes.

Here is my code

JestClientFactory factory = new JestClientFactory();

factory.setHttpClientConfig(new HttpClientConfig 
        .Builder("http://192.167.1.2:9200") 
        .defaultCredentials("user", "password")
        .multiThreaded(false) 
        //Per default this implementation will create no more than 2 concurrent connections per given route 
        .defaultMaxTotalConnectionPerRoute(2) // and no more 20 connections in total 
        .maxTotalConnection(5) 
        .build());

JestClient client = factory.getObject();

I am having 3 node cluster, so I want to pass 3 nodes in code. Any help will be appreciated.

Thank you

1

1 Answers

1
votes

Actually, as written in the link you gave, you can pass to the Builder a list, see:

JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(
    new HttpClientConfig.Builder(Arrays.asList("http://192.168.0.88:9200", "http://192.168.0.172:9200"))
        .credentialsProvider(customCredentialsProvider)
        .build()
);

Actually to be more precise, the Builder accepts a Collection<String>, see: https://github.com/searchbox-io/Jest/blob/master/jest/src/main/java/io/searchbox/client/config/HttpClientConfig.java#L127