Skip to content

Commit c6c7d9f

Browse files
committed
fix get empty response
1 parent 40e719d commit c6c7d9f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Query.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,10 @@ function setModel($model)
920920
protected function getAll($result = [])
921921
{
922922

923-
$new = [];
924-
925923
if (array_key_exists("hits", $result)) {
926924

925+
$new = [];
926+
927927
foreach ($result["hits"]["hits"] as $row) {
928928

929929
$model = $this->model ? new $this->model($row["_source"], true) : new Model($row["_source"], true);
@@ -951,9 +951,13 @@ protected function getAll($result = [])
951951
$new->scroll_id = isset($result["_scroll_id"]) ? $result["_scroll_id"] : NULL;
952952
$new->shards = (object)$result["_shards"];
953953

954-
}
954+
return $new;
955955

956-
return $new;
956+
} else {
957+
958+
return new Collection([]);
959+
960+
}
957961
}
958962

959963
/**

0 commit comments

Comments
 (0)