user1737619
user1737619

Reputation: 247

Solr:Sorting on multiple fileds, one of them is date

I'm trying to search in solr and the results have to be sorted first on date and then on name field. I'm able to get the expected result because the date is in this format: 2012-09-07T13:31:35Z.

The query goes like this:

sort=date+desc,name+desc

I don't want the sorting to be done on time also.

Upvotes: 1

Views: 104

Answers (2)

Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53603

Another option would also to store only the date part as a numeric representation (i.e. time stamp, seconds from some date in the past until the document's date at 12am).
If u follow common standards on timestamps, should be fairly easy to maintain, query and transform from timestamp to date and vice versa.

Upvotes: 0

Himanshu
Himanshu

Reputation: 113

You can use function on date e.g. in your case

sort=floor(div(ms(date),86400000))+desc,name+desc

Do note that this requires dynamicField for wildcard not set to be ignored i.e. following line should not be present in schema.xml , and if it is then you will need to comment it out or use some numeric type before you can sort as above

<dynamicField name="*" type="ignored" multiValued="true" />

Upvotes: 1

Related Questions