Harshit
Harshit

Reputation: 1565

How should I sort by date results?: Solr

I'm trying to sort results by date. The server is using Solr technology. Earlier, I was using:

urldata.sort = 'last_modified desc';

to sort by date results. Now it seems to be not working. It throws error:

enter image description here

I referred to this answer regarding sort by date in Solr: How to sort by date in SOLR?

I tried to change 'last_modified desc' to 'published_date desc' but it seems to be not working. How should I proceed to solve this error?

Upvotes: 0

Views: 847

Answers (1)

MatsLindh
MatsLindh

Reputation: 52832

The error isn't related to sorting, but that you aren't search a specific field for any particular value. Since there is no default field defined or specified in the URL, Solr has no idea what do with your search.

Try setting df in the URL, query a specific field foo:value or use qf (with (e)dismax) to specify which field Solr should sort.

Ordering, as long as the field is specified as a date field, should work automagically.

Upvotes: 1

Related Questions