本文整理汇总了Java中org.apache.lucene.search.SortField.LONG属性的典型用法代码示例。如果您正苦于以下问题:Java SortField.LONG属性的具体用法?Java SortField.LONG怎么用?Java SortField.LONG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.lucene.search.SortField
的用法示例。
在下文中一共展示了SortField.LONG属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSorter
/**
* Takes a search request and prepares a Lucene Sort object, or null if no
* sorting is required.
*/
private Sort getSorter(Search request)
{
com.tle.common.searching.SortField[] sortfields = request.getSortFields();
if( sortfields != null )
{
SortField[] convFields = new SortField[sortfields.length];
int i = 0;
for( com.tle.common.searching.SortField sortfield : sortfields )
{
FieldComparatorSource fieldComparatorSource = null;
int type = SortField.STRING;
switch( sortfield.getType() )
{
case INT:
type = SortField.INT;
break;
case LONG:
type = SortField.LONG;
break;
case SCORE:
type = SortField.SCORE;
break;
case CUSTOM:
type = SortField.CUSTOM;
fieldComparatorSource = sortfield.getFieldComparatorSource();
default:
// Stays STRING
break;
}
// @formatter:off
SortField sortField = fieldComparatorSource != null
? new SortField(sortfield.getField(), fieldComparatorSource, request.isSortReversed())
: new SortField(sortfield.getField(), type, sortfield.isReverse() ^ request.isSortReversed());
// @formatter:on
convFields[i++] = sortField;
}
return new Sort(convFields);
}
return new Sort(new SortField(null, SortField.SCORE, false));
}
示例2: search
public TopDocs search(Query query, int maxResults) throws IOException
{
Sort sort = new Sort(new SortField(FieldNames.DATE, SortField.LONG, true));
return searcher.search(query, maxResults, sort);
}