Lets take the following example,
curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
"query" : {
"term" : { "user" : "kimchy" }
}
}
Which libraries can we use in order to get the response back from the end point with those body?
Please take note that , it is not likely that GET request will have body. I am aware of this.
With elasticsearch < 5.0, you can read the Java API guide.
SearchResponse response = client.prepareSearch("twitter")
.setTypes("tweet")
.setQuery(QueryBuilders.termQuery("user", "kimchy"))
.get();
From 5.0 (and also for previous versions), you can start using the REST Java API documented here.
EDIT: the question was not precise enough. Adding this:
I built my own client at some point but switched to the Official REST one which is much more easier to use. You can see that here: https://github.com/dadoonet/fscrawler/blob/master/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/ElasticsearchClient.java.
You can see my old home made REST client here https://github.com/dadoonet/fscrawler/blob/c9c00f7da6ecdcc3bfc99bcd530ceb653088f3a4/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/ElasticsearchClient.java
But again, I'd recommend you to use the REST official client. Or be more specific about the issues you have with this.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments