function search(Search_Index_Interface $index) { $this->finalize(); try { $resultset = $index->find($this, $this->start, $this->count); } catch (Search_Elastic_SortException $e) { //on sort exception, try again without the sort field $this->sortOrder = null; $resultset = $index->find($this, $this->start, $this->count); } catch (Exception $e) { TikiLib::lib('errorreport')->report($e->getMessage()); return Search_ResultSet::create([]); } $resultset->applyTransform(function ($entry) { if (!isset($entry['_index']) || !isset($this->foreignQueries[$entry['_index']])) { foreach ($this->transformations as $trans) { $entry = $trans($entry); } } return $entry; }); foreach ($this->foreignQueries as $indexName => $query) { $resultset->applyTransform(function ($entry) use($query, $indexName) { if (isset($entry['_index']) && $entry['_index'] == $indexName) { foreach ($query->transformations as $trans) { $entry = $trans($entry); } } return $entry; }); } return $resultset; }
function search(Search_Index_Interface $index) { if ($this->sortOrder) { $sortOrder = $this->sortOrder; } else { $sortOrder = Search_Query_Order::getDefault(); } if ($this->weightCalculator) { $this->expr->walk(array($this->weightCalculator, 'calculate')); } return $index->find($this->expr, $sortOrder, $this->start, $this->count); }
function search(Search_Index_Interface $index) { if ($this->weightCalculator) { $this->expr->walk(array($this->weightCalculator, 'calculate')); } if ($this->identifierFields) { $fields = $this->identifierFields; $this->expr->walk(function (Search_Expr_Interface $expr) use($fields) { if (method_exists($expr, 'getField') && in_array($expr->getField(), $fields)) { $expr->setType('identifier'); } }); } return $index->find($this, $this->start, $this->count); }