floriansemm / SolrBundle

Solr-Integration into Symfony and Doctrine2
http://floriansemm.github.io/SolrBundle
MIT License
123 stars 72 forks source link

Help needed: Sort not working #111

Closed nirajan-panthee closed 8 years ago

nirajan-panthee commented 9 years ago

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();

floriansemm commented 9 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.

nirajan-panthee commented 9 years ago

Does the sort work for other field orther than id?

floriansemm commented 8 years ago

Well a bit late (sorry for that) but: yes it is possible.