2010-09-27 59 views
0

我有一個與日期字段排序有關的問題我有日期字段被索引爲一個字符串,看起來像「5/2/2008 4:33:30 PM」我想在這個字段的基礎上進行排序日期,時間不重要。任何建議我怎麼可以忽略來自這個領域的時間部分,只是排序日期?Solr DateField相關的問題?

回答

3

我會創建另一個專門用於此目的的字段,當您填充它時,您只需將時間從數據源中刪除,然後在此字段上排序。

0

我同意Mauricio,我們是一個單獨的領域。但我還建議記住Solr模式示例中解釋的更新字段類型(請參見下文)。特別是如果你將缺少文件的日期數據,並需要排序的第一個/最後一個。

`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"/>`