Beispiel #1
0
 public function testQueryBuildingWithData()
 {
     $query = new MoviesFromXYearQuery($this->getElasticSearcher());
     $query->addData(['year' => 2013]);
     $query->run();
     // Needed because this calls setUp inside the query.
     $expectedQuery = ['index' => 'movies', 'type' => 'movies', 'body' => ['query' => ['filtered' => ['filter' => [['term' => ['year' => 2013]]]]]]];
     $this->assertEquals($expectedQuery, $query->getRawQuery());
 }
<?php

require_once 'bootstrap.php';
if (!$searcher->indicesManager()->exists('movies')) {
    exit('Run basic.php first to create some data.');
}
$query = new MoviesFromXYearQuery($searcher);
$query->addData(['year' => 2014]);
$result = $query->run();
var_dump($result->getResults());