java - How to execute a search template within Elasticsearch by using apache.httpcomponents.httpclient -
curl -xget http://localhost:9200/contact/_search/template?pretty -d '{"id":"contact", "params": {"q": "123456", "company": "2"}}'
it works well, how can use httpclient make call?
you can achieve 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);