update ES查询改为get方法 JeroElasticsearchTemplate.java

This commit is contained in:
lijiarao
2023-12-12 10:58:28 +08:00
parent 38d3898e7e
commit c54fe2aea9
@@ -133,6 +133,16 @@ public class JeroElasticsearchTemplate {
JSONObject jsonObject = JSONObject.parseObject(response);
return jsonObject;
}
public JSONObject get(String url, JSONObject params){
String basicAuth = this.getBasicAuth();
String response = HttpRequest.get(url)
.body(params.toJSONString())
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject jsonObject = JSONObject.parseObject(response);
return jsonObject;
}
public JSONObject post(String url, JSONObject params){
String basicAuth = this.getBasicAuth();
String response = HttpRequest.post(url)
@@ -446,7 +456,7 @@ public class JeroElasticsearchTemplate {
String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
log.info("url:" + url + " ,search: " + queryObject.toJSONString());
JSONObject res = this.post(url, queryObject);
JSONObject res = this.get(url, queryObject);
log.info("url:" + url + " ,return res: \n" + res.toJSONString());
return res;
}