Skip to content

Commit

Permalink
Minor modifications to make working with result sets in custom search…
Browse files Browse the repository at this point in the history
… environments easier.
  • Loading branch information
bimthebam committed Aug 9, 2023
1 parent eda1f1b commit 123a44c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/SearchResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ public function add(Result $result): self
return $this;
}

/**
* @return array
*/
public function getIDs(): array
{
return $this->results?->column('RecordID') ?? [];
}

/**
* @var array
*/
Expand Down
21 changes: 6 additions & 15 deletions src/SearchResults/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* Class Result
* @package BimTheBam\Meilisearch\SearchResults
* @property DataObject|null $Record
* @property float $Score
*/
class Result extends ViewableData
{
Expand All @@ -24,13 +23,13 @@ class Result extends ViewableData
protected ?DataObject $record = null;

/**
* @param string $recordClassName
* @param int $recordID
* @param string $RecordClassName
* @param int $RecordID
*/
public function __construct(
protected readonly string $recordClassName,
protected readonly int $recordID,
protected readonly float $score
public readonly string $RecordClassName,
public readonly int $RecordID,
public readonly float $Score
) {
parent::__construct();
}
Expand All @@ -46,14 +45,6 @@ public function getRecord(): ?DataObject

$this->recordFetched = true;

return $this->record = DataObject::get_by_id($this->recordClassName, $this->recordID);
}

/**
* @return float
*/
public function getScore(): float
{
return $this->score;
return $this->record = DataObject::get_by_id($this->RecordClassName, $this->RecordID);
}
}

0 comments on commit 123a44c

Please sign in to comment.