searchable = $searchable; $this->transformer = $transformer; } /** * Search for a query string * * @param string $query * @param integer $limit * @param array $options * @return array of model objects */ public function find($query, $limit = null, $options = array()) { $results = $this->search($query, $limit, $options); return $this->transformer->transform($results); } public function findHybrid($query, $limit = null, $options = array()) { $results = $this->search($query, $limit, $options); return $this->transformer->hybridTransform($results); } /** * Find documents similar to one with passed id. * * @param integer $id * @param array $params * @param array $query * @return array of model objects **/ public function moreLikeThis($id, $params = array(), $query = array()) { $doc = new Document($id); $results = $this->searchable->moreLikeThis($doc, $params, $query)->getResults(); return $this->transformer->transform($results); } /** * @param $query * @param null|int $limit * @param array $options * @return array */ protected function search($query, $limit = null, $options = array()) { $queryObject = Query::create($query); if (null !== $limit) { $queryObject->setSize($limit); } $results = $this->searchable->search($queryObject, $options)->getResults(); return $results; } }