diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java index 10b4f8578..d78c96057 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java @@ -44,8 +44,8 @@ public class MetricsEsDAO extends EsDAO implements IMetricsDAO { public List multiGet(Model model, List ids) throws IOException { SearchResponse response = getClient().ids(model.getName(), ids.toArray(new String[0])); - List result = new ArrayList<>((int) response.getHits().totalHits); - for (int i = 0; i < response.getHits().totalHits; i++) { + List result = new ArrayList<>(response.getHits().getHits().length); + for (int i = 0; i < response.getHits().getHits().length; i++) { Metrics source = storageBuilder.map2Data(response.getHits().getAt(i).getSourceAsMap()); result.add(source); } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java index 6bf283630..bec72db7e 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java @@ -39,8 +39,8 @@ public class MetricsEs7DAO extends MetricsEsDAO { public List multiGet(Model model, List ids) throws IOException { SearchResponse response = getClient().ids(model.getName(), ids.toArray(new String[0])); - List result = new ArrayList<>((int) response.getHits().getTotalHits().value); - for (int i = 0; i < response.getHits().getTotalHits().value; i++) { + List result = new ArrayList<>(response.getHits().getHits().length); + for (int i = 0; i < response.getHits().getHits().length; i++) { Metrics source = storageBuilder.map2Data(response.getHits().getAt(i).getSourceAsMap()); result.add(source); }