Sorting in FOSElasticaBundle Sorting in FOSElasticaBundle elasticsearch elasticsearch

Sorting in FOSElasticaBundle


you have to create a generic Elastica\Query() object.Then you can add sort to this query with ->addSort($sort)

And later you can assign a proper query with ->setQuery();

Your example should look like this

$query = new \Elastica\Query();$query->addSort(array('price' => array('order' => 'asc')));$q = new \Elastica\Query\QueryString($searchterm);$term = new \Elastica\Filter\Term(array('isactive' => true));$filteredQuery = new \Elastica\Query\Filtered($q, $term);$query->setQuery($filteredQuery);$players = $this->get('fos_elastica.finder.xxx.player')->find($query);

Boost allows you to make one field more\less important than other within a query.