开发者

Question related to Solr DateField?

I have a question related to sorting of date field i have Date field that is indexed like a string and look like "5/2/2008 4:33:30 PM" i want to do sorting on this field on the basis of date, time does not matters. any suggestion how i could ignore the time par开发者_如何学JAVAt from this field and just sort on the date?


I would create another field specifically for this purpose, when you populate it you just strip the time out of your data source and then sort on this field.


I agree with Mauricio, us a separate field. But I would also recommend keeping in mind the pdate field type that is explained in the example Solr schema (see below). Especially if you will have missing date data on documents and will need to sort those first/last.

 `Note:
  These should only be used for compatibility with existing indexes (created with older Solr versions)
  or if "sortMissingFirst" or "sortMissingLast" functionality is needed. Use Trie based fields instead.

  Plain numeric field types that store and index the text
  value verbatim (and hence don't support range queries, since the
  lexicographic ordering isn't equal to the numeric ordering) 

<fieldType name="pdate" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>`
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜