I'm trying to connect from Java to ElasticSearch but I can only connect over HTTP. I can't use the TransportClient
. Is there a Java client wrapper around the ElasticSearch REST APIs? If so, how do I use it?
use the high level rest client: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.3/java-rest-high.html. Also, note that the rest port is 9200, for when using the java high level rest client. i added some jar file and copy the given code but it says cannot find symbol HttpHost .
There are two ways to connect to your Elasticsearch cluster: Through the RESTful API or through the Java transport client. Both ways use an endpoint URL that includes a port, such as https://ec47fc4d2c53414e1307e85726d4b9bb.us-east-1.aws.found.io:9243 .
Java Low Level REST Client: the official low-level client for Elasticsearch. It allows to communicate with an Elasticsearch cluster through http. Leaves requests marshalling and responses un-marshalling to users. It is compatible with all Elasticsearch versions.
The RestClient is used to create instances of Resource classes that are used to make the actual invocations to the service. The client can be initialized with a user supplied configuration to specify custom Provider classes, in addition to other configuration options.
Hi There is a brand new project just matching your needs. It Java based Rest API for Elasticsearch
Check it out! its name JEST
A new "official" REST-based java client will be available starting with v5.0.0-alpha4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With