","query_main" .... * @param float $duration * @param int $offsetStart * @param int $available * @param int $total * @param mixed $error * @param mixed $warning * @param ArrayCollection $suggestions * @param array $propositions * @param array $indexes * @param FacetsResponse|null $facets */ public function __construct( SearchEngineOptions $options, ArrayCollection $results, $user_query, $engine_query, $duration, $offsetStart, $available, $total, $error, $warning, ArrayCollection $suggestions, $propositions, $indexes, FacetsResponse $facets = null ) { $this->options = $options; $this->results = $results; $this->user_query = $user_query; $this->engine_query = $engine_query; $this->duration = (float) $duration; $this->offsetStart = (int) $offsetStart; $this->available = (int) $available; $this->total = (int) $total; $this->error = $error; $this->warning = $warning; $this->suggestions = $suggestions; $this->propositions = $propositions; $this->indexes = $indexes; $this->facets = $facets; } /** * @return SearchEngineOptions */ public function getOptions() { return $this->options; } /** * An collection of results * * @return ArrayCollection|RecordInterface[] */ public function getResults() { return $this->results; } /** * The query related to these results * @obsolete use getUserQuery (unparsed query) or getEngineQuery (parsed) * * @return string */ public function getQuery() { return $this->getEngineQuery(); } /** * The unparsed query related to these results * * @return string */ public function getUserQuery() { return $this->user_query; } /** * The parsed query related to these results * * @return string */ public function getEngineQuery() { return $this->engine_query; } /** * The duration of the query * * @return float */ public function getDuration() { return $this->duration; } /** * Return the number of page depending on the amount displayed on each page * * @param integer $amountPerPage * @return integer */ public function getTotalPages($amountPerPage) { return ceil($this->available / $amountPerPage); } /** * Return the number of the current page depending on the amount displayed * on each page * * @param integer $amountPerPage * @return integer */ public function getCurrentPage($amountPerPage) { return max(1, ceil(($this->offsetStart + 1) / $amountPerPage)); } /** * Return the number of results that can be returned by the search engine * * The difference with 'total' is that this method return the actual number * of results that can be fetched whereas 'total' returns the number of * results that matches the query (can be greater than available quantity) * * @return int */ public function getAvailable() { return $this->available; } /** * Return the number of items that match the query. Some items may be not * retrievable. To get the number of results that can be retrieved, use * the 'available' method * * @return int */ public function getTotal() { return $this->total; } /** * Return an error message returned by the search engine * * @return string */ public function getError() { return $this->error; } /** * Return a warning message returned by the search engine * * @return string */ public function getWarning() { return $this->warning; } /** * Return a collection of SearchEngineSuggestion * * @return ArrayCollection */ public function getSuggestions() { return $this->suggestions; } /** * Return HTML proposals * * @return string */ public function getProposals() { return $this->propositions; } /** * Return the index name where the query happened * * @return string */ public function getIndexes() { return $this->indexes; } /** * @return array */ public function getFacets() { return $this->facets->toArray(); } }