curl -XGET http://localhost:9200/contact/_search/template?pretty -d '{"id":"contact", "params": {"q": "123456", "company": "2"}}'
它运行良好,但我如何使用 httpclient 进行此调用?
最佳答案
您可以像这样轻松实现它:
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);
关于java - 如何使用 apache.httpcomponents.httpclient 在 Elasticsearch 中执行搜索模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37669754/