简体   繁体   English

使用Java Client连接到外部HTTPS Elasticsearch

[英]Connect to external HTTPS Elasticsearch with Java Client

Since I'd want use the Elasticsearch' Java API, I'm trying to connect to external Elasticsearch's REST Server by using the Java TransportClient, the URL I have to call looks like: 由于我想使用Elasticsearch的Java API,因此尝试通过使用Java TransportClient连接到外部Elasticsearch的REST Server,因此我必须调用的URL如下:

https://ssl-secure-host/their-index/their-type/_search

Obviously I first trusted the certification provided by ssl-secure-host by using the keytool and generated the keystore.jks . 显然,我首先信任使用keytool的ssl-secure-host提供的证书,并生成了keystore.jks

I don't have any other information about the elasticsearch's index, nodes, etc, I have only the URL above. 我没有关于elasticsearch的索引,节点等的任何其他信息,我只有上面的URL。

This is the TransportClient I'm writting in order to establish a connection: 这是我为建立连接而编写的TransportClient:

ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
    .put("cluster.name", "elasticsearch")
    .put("discovery.zen.ping.multicast.enabled", false)
    .put("shield.user", "user:password")
    .put("shield.ssl.truststore.path", "/Users/me/path/cert/keystore.jks")
    .put("shield.ssl.truststore.password", "changeit")
    .put("shield.transport.ssl", true);

TransportClient client = new TransportClient(settings)
    .addTransportAddress(new InetSocketTransportAddress("ssl-secure-host", ?????));

Could it be possible to establish a connection in any other way or I have to ask to my provider more information about the host , port , etc? 是否可以通过任何其他方式建立连接,或者我必须向我的提供商询问有关主机端口等的更多信息?

Or, Do I have to resign myself to do this by implementing a simple REST client to query the Elasticsearch's index other people provide me? 或者,我是否必须辞职以实现一个简单的REST客户端来查询其他人提供给我的Elasticsearch索引来做到这一点?

Could it be possible that an Apache HTTP Server exists in the front of elasticsearch nodes? 在Elasticsearch节点的前面是否可能存在Apache HTTP服务器?

Thank you very much in advance :) 提前非常感谢您:)

You can use JEST library. 您可以使用JEST库。 It s an HTTP client for ElasticSearch. 它是ElasticSearch的HTTP客户端。 So you can use it instead the transport client provided by Elasticsearch 因此,您可以使用它代替Elasticsearch提供的传输客户端

check this link: https://github.com/searchbox-io/Jest 检查此链接: https : //github.com/searchbox-io/Jest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM