How to set sort order in query by using Elastica_Query_Bool() class?
Set sort order by using Elastica_Query_Bool()
In a symfony2 project I implemented elastic search by using FOSElisticaBundle and used Elastica\Query\Bool() to make query and found that there isn’t any method to set sort order in query but Elastica\Query have so I manage to make query with sort parameters as following.
use Elastica\Query;
$bool = new Query\Bool();
bool->addMust(..); /// any criteria
$q = new Query($bool);
$sort = array("field" => array("order" => "asc"));
$q->setSort(array($sort));
I hope above code will be helpful.
