当前位置: 首页>>代码示例>>Java>>正文


Java FieldComparatorSource类代码示例

本文整理汇总了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);
				}
			};
		}
	});
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:23,代码来源:PartitionMapper.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:SortField.java

示例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());
		}
	};
}
 
开发者ID:equella,项目名称:Equella,代码行数:14,代码来源:TaskSortSection.java

示例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));
				}
			};
		}
	});
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:21,代码来源:KeyMapper.java

示例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();
				}
			}
	));
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:12,代码来源:LuceneEngine.java

示例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);
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:SortableBinaryField.java

示例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);
        }
    })};
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:17,代码来源:ClusteringKeyMapper.java

示例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;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:29,代码来源:ShardDoc.java

示例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;
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:29,代码来源:ShardFieldSortedHitQueue.java

示例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;
}
 
开发者ID:atware,项目名称:solr-leaning2rank,代码行数:10,代码来源:RankingComponent.java

示例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;
}
 
开发者ID:atware,项目名称:solr-leaning2rank,代码行数:8,代码来源:RankingComparatorTest.java

示例12: getFieldComparatorSource

import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
public FieldComparatorSource getFieldComparatorSource()
{
	return fieldComparatorSource;
}
 
开发者ID:equella,项目名称:Equella,代码行数:5,代码来源:SortField.java

示例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));
}
 
开发者ID:equella,项目名称:Equella,代码行数:45,代码来源:ItemIndex.java

示例14: getSortComparatorSource

import org.apache.lucene.search.FieldComparatorSource; //导入依赖的package包/类
@Override
public FieldComparatorSource getSortComparatorSource() {

    return null;
}
 
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:6,代码来源:CustomFieldMock.java


注:本文中的org.apache.lucene.search.FieldComparatorSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。