本文整理汇总了Java中org.apache.lucene.search.FieldComparatorSource类的典型用法代码示例。如果您正苦于以下问题:Java FieldComparatorSource类的具体用法?Java FieldComparatorSource怎么用?Java FieldComparatorSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FieldComparatorSource类属于org.apache.lucene.search包,在下文中一共展示了FieldComparatorSource类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sortField
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
/**
* Returns a Lucene {@link SortField} for sorting documents/rows according
* to the partition key.
*
* @return a sort field for sorting by partition key
*/
public SortField sortField() {
return new SortField(FIELD_NAME, new FieldComparatorSource() {
@Override
public FieldComparator<?> newComparator(String field, int hits, int sort, boolean reversed)
throws IOException {
return new FieldComparator.TermValComparator(hits, field, false) {
@Override
public int compareValues(BytesRef val1, BytesRef val2) {
ByteBuffer bb1 = ByteBufferUtils.byteBuffer(val1);
ByteBuffer bb2 = ByteBufferUtils.byteBuffer(val2);
return ByteBufferUtil.compareUnsigned(bb1, bb2);
}
};
}
});
}
示例2: SortField
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
private SortField(String field, boolean reverse, Type type, FieldComparatorSource fieldComparatorSource)
{
this.field = field;
this.reverse = reverse;
this.type = type;
this.fieldComparatorSource = fieldComparatorSource;
}
示例3: createCurrentUserFirstComparator
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
private static FieldComparatorSource createCurrentUserFirstComparator()
{
return new FieldComparatorSource()
{
@Override
public FieldComparator<Integer> newComparator(final String fieldName, final int numHits, final int sortPos,
boolean reversed) throws IOException
{
return new CustomLuceneSortComparator(numHits, fieldName, CurrentUser.getUserID());
}
};
}
示例4: sortField
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
/**
* Returns a Lucene {@link SortField} to sort documents by primary key
* according to Cassandra's natural order.
*
* @return the sort field
*/
public SortField sortField() {
return new SortField(FIELD_NAME, new FieldComparatorSource() {
@Override
public FieldComparator<?> newComparator(String field, int hits, int sort, boolean reversed)
throws IOException {
return new FieldComparator.TermValComparator(hits, field, false) {
@Override
public int compareValues(BytesRef val1, BytesRef val2) {
return entry(val1).compareTo(entry(val2));
}
};
}
});
}
示例5: setSortFieldRandom
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
private void setSortFieldRandom() {
SORT.setSort(new SortField(
"",
new FieldComparatorSource() {
@Override
public FieldComparator<Integer> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
return new RandomOrderFieldComparator();
}
}
));
}
示例6: BinarySortField
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
public BinarySortField(final String field, final boolean reverse) {
super(field, new FieldComparatorSource() {
@Override
public FieldComparator.TermOrdValComparator newComparator
(final String fieldname, final int numHits, final int sortPos, final boolean reversed) throws IOException {
return new FieldComparator.TermOrdValComparator(numHits, fieldname);
}}, reverse);
}
示例7: sortFields
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
/**
* Returns a Lucene {@link SortField} array for sorting documents/rows according to the column family name.
*
* @return A Lucene {@link SortField} array for sorting documents/rows according to the column family name.
*/
public SortField[] sortFields() {
return new SortField[]{new SortField(FIELD_NAME, new FieldComparatorSource() {
@Override
public FieldComparator<?> newComparator(String field,
int hits,
int sort,
boolean reversed) throws IOException {
return new ClusteringKeySorter(ClusteringKeyMapper.this, hits, field);
}
})};
}
示例8: getCachedComparator
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
Comparator getCachedComparator(String fieldname, SortField.Type type, FieldComparatorSource factory) {
Comparator comparator = null;
switch (type) {
case SCORE:
comparator = comparatorScore(fieldname);
break;
case STRING:
comparator = comparatorNatural(fieldname);
break;
case CUSTOM:
if (factory instanceof MissingStringLastComparatorSource){
comparator = comparatorMissingStringLast(fieldname);
} else {
// TODO: support other types such as random... is there a way to
// support generically? Perhaps just comparing Object
comparator = comparatorNatural(fieldname);
// throw new RuntimeException("Custom sort not supported factory is "+factory.getClass());
}
break;
case DOC:
// TODO: we can support this!
throw new RuntimeException("Doc sort not supported");
default:
comparator = comparatorNatural(fieldname);
break;
}
return comparator;
}
示例9: getCachedComparator
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
Comparator getCachedComparator(String fieldname, SortField.Type type, FieldComparatorSource factory) {
Comparator comparator = null;
switch(type) {
case SCORE:
comparator = comparatorScore(fieldname);
break;
case STRING:
comparator = comparatorNatural(fieldname);
break;
case CUSTOM:
if(factory instanceof MissingStringLastComparatorSource) {
comparator = comparatorMissingStringLast(fieldname);
} else {
// TODO: support other types such as random... is there a way to
// support generically? Perhaps just comparing Object
comparator = comparatorNatural(fieldname);
// throw new RuntimeException("Custom sort not supported factory is "+factory.getClass());
}
break;
case DOC:
// TODO: we can support this!
throw new RuntimeException("Doc sort not supported");
default:
comparator = comparatorNatural(fieldname);
break;
}
return comparator;
}
示例10: createSort
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
private Sort createSort(ResponseBuilder rb, SolrParams params) {
Query query = rb.getQuery();
FeatureExtractor extractor = extractorFactory.create(params, query);
Classifier classifier = classifierFactory.createClassifier();
FieldComparatorSource comparator = new RankingComparatorSource(
extractor, classifier, params, query);
Sort sort = new Sort(new SortField("ranking", comparator));
return sort;
}
示例11: getRaningSort
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
private Sort getRaningSort(Query query) {
FieldComparatorSource comparator = new RankingComparatorSource(
extractor, classifier, null, query);
Sort sort = new Sort(new SortField[] { new SortField("ranking",
comparator) });
return sort;
}
示例12: getFieldComparatorSource
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
public FieldComparatorSource getFieldComparatorSource()
{
return fieldComparatorSource;
}
示例13: getSorter
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
/**
* 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));
}
示例14: getSortComparatorSource
import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
@Override
public FieldComparatorSource getSortComparatorSource() {
return null;
}