Sample code to retrieve data from ElasticSearch protected by SearchGuard

Hello group,

Can someone shares the sample Java code to retrieve data from ElasticSearch protected by SearchGuard?

Thank you,
A.G.

If you mean how to use Transport Clients with Search Guard, there’s a two-part article about that on our blog:

···

On Thursday, June 29, 2017 at 9:49:20 PM UTC+2, A.G. Strider wrote:

Hello group,

Can someone shares the sample Java code to retrieve data from ElasticSearch protected by SearchGuard?

Thank you,
A.G.

Thank you, Jochen. These two articles do not provide full example, but rather some pieces of code and configuration.

BTW, is there any other way to access ElasticSearch protected by SearchGuard except using transport client?

···

On Thursday, June 29, 2017 at 12:51:24 PM UTC-7, Jochen Kressin wrote:

If you mean how to use Transport Clients with Search Guard, there’s a two-part article about that on our blog:

https://floragunn.com/searchguard-elasicsearch-transport-clients/
https://floragunn.com/transport-client-authentication-authorization/

On Thursday, June 29, 2017 at 9:49:20 PM UTC+2, A.G. Strider wrote:

Hello group,

Can someone shares the sample Java code to retrieve data from ElasticSearch protected by SearchGuard?

Thank you,
A.G.

Yes, the articles are meant as a guideline explaining the principles. Which are: Add the SearchGuardSSL plugin to the transport client, add the keystore- and truststore and optionally add Basic Authentication credentials. There’s really not much more to it. Once you have instantiated the transport client, the usage is identical to a non-SG secured cluster, so you will find many examples out there, e.g. on the Elasticsearch docs.

Alternatively, you can use the Java REST client to connect via HTTP(S):

···

On Friday, June 30, 2017 at 1:00:01 AM UTC+2, A.G. Strider wrote:

Thank you, Jochen. These two articles do not provide full example, but rather some pieces of code and configuration.

BTW, is there any other way to access ElasticSearch protected by SearchGuard except using transport client?

On Thursday, June 29, 2017 at 12:51:24 PM UTC-7, Jochen Kressin wrote:

If you mean how to use Transport Clients with Search Guard, there’s a two-part article about that on our blog:

https://floragunn.com/searchguard-elasicsearch-transport-clients/
https://floragunn.com/transport-client-authentication-authorization/

On Thursday, June 29, 2017 at 9:49:20 PM UTC+2, A.G. Strider wrote:

Hello group,

Can someone shares the sample Java code to retrieve data from ElasticSearch protected by SearchGuard?

Thank you,
A.G.