Open mavencode01 opened 9 years ago
You can't put it on the ElasticSearchService
as this is a vert.x proxy service that can go over the event bus. It would be possible to put on the concrete implementation, but it is not a valid type for the proxy service.
@adrianluisgonzalez that's exactly what am trying to achieve here...any suggestion on how to fix this ?
What do you need the transport client for? Should additional functionality be added to ElasticSearchService
? If you really need it, then perhaps you shouldn't be using a vert.x service proxy.
If you are not using the proxy version of the service (ElasticSearchServiceVertxEBProxy
) then you should have an instance of an InternalElasticSearchService
which you can cast and call getClient()
.
@adrianluisgonzalez Technically, I'm using another library - https://github.com/NLPchina/elasticsearch-sql/tree/elastic2.0 for parsing SQLs to Elasticsearch DSL and this requires the ES client.
Here is what I have to as a quick fix:
vertx.executeBlocking(action -> {
Settings settings = Settings.builder()
.put("cluster.name", "myClusterName").build();
esClient = TransportClient.builder().settings(settings).build();
TransportClient client = TransportClient.builder().settings(settings).build();
JsonArray transportHostArray = esConfig.getJsonArray("transportAddresses");
transportHostArray.forEach(host -> {
JsonObject hostInfo = (JsonObject)host;
String hostAddress = hostInfo.getString("hostname");
int port = hostInfo.getInteger("port");
InetSocketTransportAddress transportAddress;
try {
transportAddress = new InetSocketTransportAddress(InetAddress.getByName(hostAddress), port);
client.addTransportAddress(transportAddress);
} catch (Exception e) {
action.fail(e);
e.printStackTrace();
return;
}
});
action.complete(client);
}, res -> {
if (res.succeeded()){
//client available!
esClient = (TransportClient)res.result()
}
});
I've a requirement to expose the transport client in my application but seems the service does not correctly offer that.
I tried adding the getClient to the Elasticsearchservice but I got some exception relating to abstractmethod not defined.
Any ideas ?