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


Java FieldComparator类代码示例

本文整理汇总了Java中org.apache.lucene.search.FieldComparator的典型用法代码示例。如果您正苦于以下问题:Java FieldComparator类的具体用法?Java FieldComparator怎么用?Java FieldComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldComparator类属于org.apache.lucene.search包,在下文中一共展示了FieldComparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) {
    assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName());

    final Long dMissingValue = (Long) missingObject(missingValue, reversed);
    // NOTE: it's important to pass null as a missing value in the constructor so that
    // the comparator doesn't check docsWithField since we replace missing values in select()
    return new FieldComparator.LongComparator(numHits, null, null) {
        @Override
        protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException {
            final SortedNumericDocValues values = indexFieldData.load(context).getLongValues();
            final NumericDocValues selectedValues;
            if (nested == null) {
                selectedValues = sortMode.select(values, dMissingValue);
            } else {
                final BitSet rootDocs = nested.rootDocs(context);
                final DocIdSetIterator innerDocs = nested.innerDocs(context);
                selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
            }
            return selectedValues;
        }

    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:LongValuesComparatorSource.java

示例2: newComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) {
    assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName());

    final float dMissingValue = (Float) missingObject(missingValue, reversed);
    // NOTE: it's important to pass null as a missing value in the constructor so that
    // the comparator doesn't check docsWithField since we replace missing values in select()
    return new FieldComparator.FloatComparator(numHits, null, null) {
        @Override
        protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException {
            final SortedNumericDoubleValues values = indexFieldData.load(context).getDoubleValues();
            final NumericDoubleValues selectedValues;
            if (nested == null) {
                selectedValues = sortMode.select(values, dMissingValue);
            } else {
                final BitSet rootDocs = nested.rootDocs(context);
                final DocIdSetIterator innerDocs = nested.innerDocs(context);
                selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
            }
            return selectedValues.getRawFloatValues();
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:FloatValuesComparatorSource.java

示例3: newComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
    return new FieldComparator<Object>() {
        @Override
        public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
            return LEAF_FIELD_COMPARATOR;
        }

        @Override
        public int compare(int slot1, int slot2) {
            return 0;
        }

        @Override
        public void setTopValue(Object value) {
        }

        @Override
        public Object value(int slot) {
            return missingValue;
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:NullFieldComparatorSource.java

示例4: newComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
    assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName());

    final Long dMissingValue = (Long) missingObject(missingValue, reversed);
    // NOTE: it's important to pass null as a missing value in the constructor so that
    // the comparator doesn't check docsWithField since we replace missing values in select()
    return new FieldComparator.LongComparator(numHits, null, null) {
        @Override
        protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException {
            final SortedNumericDocValues values = indexFieldData.load(context).getLongValues();
            final NumericDocValues selectedValues;
            if (nested == null) {
                selectedValues = sortMode.select(values, dMissingValue);
            } else {
                final BitSet rootDocs = nested.rootDocs(context);
                final DocIdSetIterator innerDocs = nested.innerDocs(context);
                selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
            }
            return selectedValues;
        }

    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:LongValuesComparatorSource.java

示例5: newComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
    assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName());

    final float dMissingValue = (Float) missingObject(missingValue, reversed);
    // NOTE: it's important to pass null as a missing value in the constructor so that
    // the comparator doesn't check docsWithField since we replace missing values in select()
    return new FieldComparator.FloatComparator(numHits, null, null) {
        @Override
        protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException {
            final SortedNumericDoubleValues values = indexFieldData.load(context).getDoubleValues();
            final NumericDoubleValues selectedValues;
            if (nested == null) {
                selectedValues = sortMode.select(values, dMissingValue);
            } else {
                final BitSet rootDocs = nested.rootDocs(context);
                final DocIdSetIterator innerDocs = nested.innerDocs(context);
                selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
            }
            return selectedValues.getRawFloatValues();
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:FloatValuesComparatorSource.java

示例6: sortField

import org.apache.lucene.search.FieldComparator; //导入依赖的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

示例7: comparatorFieldComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
Comparator<ShardDoc> comparatorFieldComparator(SortField sortField) {
  final FieldComparator fieldComparator;
  try {
    fieldComparator = sortField.getComparator(0, 0);
  } catch (IOException e) {
    throw new RuntimeException("Unable to get FieldComparator for sortField " + sortField);
  }

  return new ShardComparator(sortField) {
    // Since the PriorityQueue keeps the biggest elements by default,
    // we need to reverse the field compare ordering so that the
    // smallest elements are kept instead of the largest... hence
    // the negative sign.
    @Override
    public int compare(final ShardDoc o1, final ShardDoc o2) {
      //noinspection unchecked
      return -fieldComparator.compareValues(sortVal(o1), sortVal(o2));
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:ShardDoc.java

示例8: comparatorFieldComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
Comparator<ShardDoc> comparatorFieldComparator(SortField sortField) {
  final FieldComparator fieldComparator;
  try {
    fieldComparator = sortField.getComparator(0, 0);
  } catch (IOException e) {
    throw new RuntimeException("Unable to get FieldComparator for sortField " + sortField);
  }

  return new ShardComparator(sortField) {
    // Since the PriorityQueue keeps the biggest elements by default,
    // we need to reverse the field compare ordering so that the
    // smallest elements are kept instead of the largest... hence
    // the negative sign.
    @Override
    @SuppressWarnings("unchecked")
    public int compare(final ShardDoc o1, final ShardDoc o2) {
      // noinspection unchecked
      return -fieldComparator.compareValues(sortVal(o1), sortVal(o2));
    }
  };
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:23,代码来源:ShardFieldSortedHitQueue.java

示例9: newComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) {
    assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName());

    final double dMissingValue = (Double) missingObject(missingValue, reversed);
    // NOTE: it's important to pass null as a missing value in the constructor so that
    // the comparator doesn't check docsWithField since we replace missing values in select()
    return new FieldComparator.DoubleComparator(numHits, null, null) {
        @Override
        protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException {
            final SortedNumericDoubleValues values = getValues(context);
            final NumericDoubleValues selectedValues;
            if (nested == null) {
                selectedValues = sortMode.select(values, dMissingValue);
            } else {
                final BitSet rootDocs = nested.rootDocs(context);
                final DocIdSetIterator innerDocs = nested.innerDocs(context);
                selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
            }
            return selectedValues.getRawDoubleValues();
        }
        @Override
        public void setScorer(Scorer scorer) {
            DoubleValuesComparatorSource.this.setScorer(scorer);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:DoubleValuesComparatorSource.java

示例10: createCurrentUserFirstComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的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

示例11: newComparator

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
    assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName());

    final double dMissingValue = (Double) missingObject(missingValue, reversed);
    // NOTE: it's important to pass null as a missing value in the constructor so that
    // the comparator doesn't check docsWithField since we replace missing values in select()
    return new FieldComparator.DoubleComparator(numHits, null, null) {
        @Override
        protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException {
            final SortedNumericDoubleValues values = getValues(context);
            final NumericDoubleValues selectedValues;
            if (nested == null) {
                selectedValues = sortMode.select(values, dMissingValue);
            } else {
                final BitSet rootDocs = nested.rootDocs(context);
                final DocIdSetIterator innerDocs = nested.innerDocs(context);
                selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
            }
            return selectedValues.getRawDoubleValues();
        }
        @Override
        public void setScorer(Scorer scorer) {
            DoubleValuesComparatorSource.this.setScorer(scorer);
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:DoubleValuesComparatorSource.java

示例12: sortField

import org.apache.lucene.search.FieldComparator; //导入依赖的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

示例13: setSortFieldRandom

import org.apache.lucene.search.FieldComparator; //导入依赖的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

示例14: setScorer

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@Override
public void setScorer(Scorer scorer) throws IOException {
  this.scorer = scorer;
  for (GroupHead groupHead : groups.values()) {
    for (FieldComparator<?> comparator : groupHead.comparators) {
      comparator.setScorer(scorer);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:FunctionAllGroupHeadsCollector.java

示例15: GroupHead

import org.apache.lucene.search.FieldComparator; //导入依赖的package包/类
@SuppressWarnings({"unchecked","rawtypes"})
private GroupHead(MutableValue groupValue, Sort sort, int doc) throws IOException {
  super(groupValue, doc + readerContext.docBase);
  final SortField[] sortFields = sort.getSort();
  comparators = new FieldComparator[sortFields.length];
  for (int i = 0; i < sortFields.length; i++) {
    comparators[i] = sortFields[i].getComparator(1, i).setNextReader(readerContext);
    comparators[i].setScorer(scorer);
    comparators[i].copy(0, doc);
    comparators[i].setBottom(0);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:FunctionAllGroupHeadsCollector.java


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