Skip to content

Commit

Permalink
fix(dx): Throw exception if empty index in ResultSetBuilder #116 (#125)
Browse files Browse the repository at this point in the history
Refs: #116
  • Loading branch information
MrYamous authored Nov 30, 2022
1 parent 787284e commit f918cd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Add Exception if Result's index is empty in `JoliCode\Elastically\ResultSetBuilder` #116
- Fix OpenSearch unallowed "_all" indices for regular user #122

## [1.5.3] - 2022-10-10
Expand Down
5 changes: 5 additions & 0 deletions src/ResultSetBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace JoliCode\Elastically;

use Elastica\Document;
use Elastica\Exception\RuntimeException;
use Elastica\Query;
use Elastica\Response;
use Elastica\ResultSet;
Expand Down Expand Up @@ -67,6 +68,10 @@ public function buildModelFromDocument(Document $document)

private function buildModelFromResult(Result $result)
{
if (!$result->getIndex()) {
throw new RuntimeException('Returned index is empty. Check your "filter_path".');
}

return $this->buildModel($result->getSource(), $result->getIndex(), [
self::RESULT_KEY => $result,
]);
Expand Down

0 comments on commit f918cd0

Please sign in to comment.