How to sort by date in SOLR?

I want to sort the results and grades returned from the SOLR search, how can I get grades based on the date, as shown below:

Suppose for keywords "football" 12-10-2012 - 3.2 13-10-2012 - 1.5 

My solr date is below:

  <field name="published_date" datetimeformat="dd-MM-yyyy" type="date" indexed="true" stored="true"/> 

I checked these docs but could not find this.

Thanks.

+8
search solr
source share
2 answers

You can pass sort parameter to URL

eg. sort=published_date desc for documents by published date in descending order.

If you want to sort the score and date, you can use sort=score desc, published_date desc

+25
source share

taken from wiki

 Although not technically a Syntax difference, please note that if you use the Solr "DateField" type, any queries on those fields (typically range queries) should use either the Complete ISO 8601 Date syntax that field supports, or the DateMath Syntax to get relative dates. Examples: timestamp:[* TO NOW] createdate:[1976-03-06T23:59:59.999Z TO *] createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z] pubdate:[NOW-1YEAR/DAY TO NOW/DAY+1DAY] createdate:[1976-03-06T23:59:59.999Z TO 1976-03-06T23:59:59.999Z+1YEAR] createdate:[1976-03-06T23:59:59.999Z/YEAR TO 1976-03-06T23:59:59.999Z] NOTE:TO must be uppercase, or Solr will report a 'Range Goop' error. 

combine this with this and the job is done :) it's pretty easy, it just takes a few attempts at the beginning

small editing: this method allows you to extract values ​​based on a range of dates and apply scoring to them according to their values. apparently you were asking for help on how to get sorting by base account and date, so my answer is not 100% correct.

+1
source share

All Articles