2010-09-27 56 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"/>`