Closed nirajan-panthee closed 8 years ago
your code is correct, the problem is the value of the field id
internally: the value is a compound of document name and entity-id. In your case the value would look like this: product_1234
. So sorting by solr is not possible. You have to implement your own sorting function.
Does the sort work for other field orther than id?
Well a bit late (sorry for that) but: yes it is possible.
Here is my code, result is not sorted
$query = $this->get('solr.client')->createQuery('ProductBundle:Product'); $query->addSearchTerm('name', $q); $query->addSort('Id', $query::SORT_DESC); $query->setRows(1000); $productList = $query->getResult();