Java Programmer
Java Programmer

Reputation: 1413

AWS elasticsearch access Request signing using Java

I want to connect to elastic search from Java. Elastic search domain is configured in AWS. I am using Jest library for this. Currently i have added my system ip in the elastic search configure access section. So i can access ES endpoint. But this is not the right way of doing it. What are the approches to it ? i know about signing the request but could not find any good reference of how to do it in java. Can anyone give some thoughts ? This is how my code looks like

JestClientFactory factory = new JestClientFactory();
    factory.setHttpClientConfig(new HttpClientConfig.Builder(elasticSearchserverUrl).connTimeout(10000).readTimeout(10000)
            .multiThreaded(true).build());

JestClient client = factory.getObject();
Search.Builder searchBuilder = new Search.Builder(query).addIndices(indices).addType(type);

    try {
        SearchResult result = client.execute(searchBuilder.build());

        List<Hit<String, Void>> hits = result.getHits(String.class);
        for (Hit<String, Void> hit : hits) {
            String log = hit.source;
            System.out.println(log);


        }

    } catch (IOException e) {

    }

Upvotes: 0

Views: 1042

Answers (0)

Related Questions