diff --git a/ActiveDataProvider.php b/ActiveDataProvider.php
index <HASH>..<HASH> 100644
--- a/ActiveDataProvider.php
+++ b/ActiveDataProvider.php
@@ -116,7 +116,10 @@ class ActiveDataProvider extends \yii\data\ActiveDataProvider
         }
 
         $results = $this->getQueryResults();
-        return isset($results['hits']['total']) ? (int)$results['hits']['total'] : 0;
+        if (isset($results['hits']['total'])) {
+            return is_array($results['hits']['total']) ? (int)$results['hits']['total']['value'] : (int)$results['hits']['total'];
+        }
+        return 0;
     }
 
     /**
Fix prepareTotalCount() support elasticsearch 7.x

Fix the return value of prepareTotalCount() in ActiveDataProvider to support elasticsearch 7.x