Skip to content

Commit d358c0f

Browse files
author
qiubo
committed
修复ES total 查询转换异常问题
1 parent be60ae8 commit d358c0f

File tree

1 file changed

+4
-1
lines changed
  • km-persistence/src/main/java/com/xiaojukeji/know/streaming/km/persistence/es/dao

1 file changed

+4
-1
lines changed

km-persistence/src/main/java/com/xiaojukeji/know/streaming/km/persistence/es/dao/BaseMetricESDAO.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ protected int handleESQueryResponseCount(ESQueryResponse response){
336336
if(null == response || null == response.getHits()
337337
|| null ==response.getHits().getUnusedMap()){return -1;}
338338

339-
return Integer.valueOf(response.getHits().getUnusedMap().getOrDefault(TOTAL, 0).toString());
339+
// "total" : {"value": 123 , "relation": "XX "}
340+
JSONObject jsonObjectTotal = (JSONObject) response.getHits().getUnusedMap().getOrDefault(TOTAL, 0);
341+
342+
return Integer.valueOf(jsonObjectTotal.get(VALUE).toString());
340343
}
341344

342345
protected <T extends BaseMetricESPO> T filterMetrics(T t, List<String> metricNames){

0 commit comments

Comments
 (0)