/** * Build and execute the query. * * @return AbstractResultParser */ public function run() { $query = $this->buildQuery(); // Execute the query. $rawResults = $this->searcher->getClient()->search($query); // Pass response to the class that will do something with it. $resultParser = $this->getResultParser(); $resultParser->setRawResults($rawResults); return $resultParser; }
<?php require '../tests/bootstrap.php'; use ElasticSearcher\Environment; use ElasticSearcher\ElasticSearcher; $env = new Environment(['hosts' => [ELASTICSEARCH_HOST]]); $searcher = new ElasticSearcher($env); // Register indexes. $moviesIndex = new MoviesIndex(); $searcher->indicesManager()->register($moviesIndex);