update ES查询改为get方法 JeroElasticsearchTemplate.java
This commit is contained in:
+11
-1
@@ -133,6 +133,16 @@ public class JeroElasticsearchTemplate {
|
|||||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
return jsonObject;
|
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){
|
public JSONObject post(String url, JSONObject params){
|
||||||
String basicAuth = this.getBasicAuth();
|
String basicAuth = this.getBasicAuth();
|
||||||
String response = HttpRequest.post(url)
|
String response = HttpRequest.post(url)
|
||||||
@@ -446,7 +456,7 @@ public class JeroElasticsearchTemplate {
|
|||||||
String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
|
String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
|
||||||
|
|
||||||
log.info("url:" + url + " ,search: " + queryObject.toJSONString());
|
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());
|
log.info("url:" + url + " ,return res: \n" + res.toJSONString());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user