vendor/ibexa/core/src/contracts/Repository/Values/Content/Search/SearchResult.php line 19

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace Ibexa\Contracts\Core\Repository\Values\Content\Search;
  8. use ArrayIterator;
  9. use Ibexa\Contracts\Core\Repository\Values\ValueObject;
  10. use Iterator;
  11. use IteratorAggregate;
  12. /**
  13.  * This class represents a search result.
  14.  */
  15. class SearchResult extends ValueObject implements IteratorAggregateAggregationResultAwareInterface
  16. {
  17.     /**
  18.      * The facets for this search.
  19.      *
  20.      * @var \Ibexa\Contracts\Core\Repository\Values\Content\Search\Facet[]
  21.      *
  22.      * @deprecated since eZ Platform 3.2.0, to be removed in Ibexa 4.0.0.
  23.      */
  24.     public $facets = [];
  25.     /**
  26.      * @var \Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResultCollection
  27.      */
  28.     public $aggregations;
  29.     /**
  30.      * The value objects found for the query.
  31.      *
  32.      * @var \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit[]
  33.      */
  34.     public $searchHits = [];
  35.     /**
  36.      * If spellcheck is on this field contains a collated query suggestion where in the appropriate
  37.      * criterions the wrong spelled value is replaced by a corrected one (TBD).
  38.      *
  39.      * @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion
  40.      *
  41.      * @deprecated since Ibexa 4.6.0, to be removed in Ibexa 5.0.0.
  42.      */
  43.     public $spellSuggestion;
  44.     public ?SpellcheckResult $spellcheck null;
  45.     /**
  46.      * The duration of the search processing in ms.
  47.      *
  48.      * @var int
  49.      */
  50.     public $time;
  51.     /**
  52.      * Indicates if the search has timed out.
  53.      *
  54.      * @var bool
  55.      */
  56.     public $timedOut;
  57.     /**
  58.      * The maximum score of this query.
  59.      *
  60.      * @var float
  61.      */
  62.     public $maxScore;
  63.     /**
  64.      * The total number of searchHits.
  65.      *
  66.      * `null` if Query->performCount was set to false and search engine avoids search lookup.
  67.      *
  68.      * @var int|null
  69.      */
  70.     public $totalCount;
  71.     public function __construct(array $properties = [])
  72.     {
  73.         if (!isset($properties['aggregations'])) {
  74.             $properties['aggregations'] = new AggregationResultCollection();
  75.         }
  76.         parent::__construct($properties);
  77.     }
  78.     public function getSpellcheck(): ?SpellcheckResult
  79.     {
  80.         return $this->spellcheck;
  81.     }
  82.     public function getAggregations(): ?AggregationResultCollection
  83.     {
  84.         return $this->aggregations;
  85.     }
  86.     public function getIterator(): Iterator
  87.     {
  88.         return new ArrayIterator($this->searchHits);
  89.     }
  90. }
  91. class_alias(SearchResult::class, 'eZ\Publish\API\Repository\Values\Content\Search\SearchResult');