【发布时间】:2013-07-30 16:12:45
【问题描述】:
我正在尝试对搜索结果进行排序,但我只是使用以下代码获得未排序的结果(在此示例中,我查询所有结果):
$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();
作为参考,我将 FOSElasticaBundle 与 Symfony2 项目一起使用(使用 $type = $this->container->get('fos_elastica.index.website.myType');),但这应该没什么区别。
如果我直接在浏览器上使用http://localhost:9200/website/myType/_search?sort=id:desc&pretty=true 进行查询,我会得到正确排序的结果。
【问题讨论】:
标签: elastica