Reputation: 163
curl -XGET http://localhost:9200/contact/_search/template?pretty -d '{"id":"contact", "params": {"q": "123456", "company": "2"}}'
It works well, but how can I use httpclient to make this call?
Upvotes: 0
Views: 75
Reputation: 217424
You can easily achieve it like this:
StringRequestEntity entity = new StringRequestEntity(
"{\"id\":\"contact\", \"params\": {\"q\": \"123456\", \"company\": \"2\"}}",
"application/json",
"UTF-8");
PostMethod post = new PostMethod("http://localhost:9200/contact/_search/template");
postMethod.addParameter("pretty", "");
postMethod.setRequestEntity(entity);
int statusCode = httpClient.executeMethod(post);
Upvotes: 1