I'm trying to get search results sorted, but I just get the unsorted results with the following code (in this example I query for all results):
$query = new \Elastica\Query();
$query->setSort(array('id' => array('order' => 'desc')));
$resultSet = $type->search($query); // where $type is an elastica type object
$results = $resultSet->getResults();
For reference, I'm using the FOSElasticaBundle with a Symfony2 project (using $type = $this->container->get('fos_elastica.index.website.myType');
), but that should not make a difference.
If I make the query directly on the browser with http://localhost:9200/website/myType/_search?sort=id:desc&pretty=true
, I get the results correctly sorted.