Java 类org.apache.lucene.search.FieldComparatorSource 实例源码

项目:cassandra-fhir-index    文件:PartitionMapper.java   
/**
 * 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);
                }
            };
        }
    });
}
项目:Equella    文件:SortField.java   
private SortField(String field, boolean reverse, Type type, FieldComparatorSource fieldComparatorSource)
{
    this.field = field;
    this.reverse = reverse;
    this.type = type;
    this.fieldComparatorSource = fieldComparatorSource;
}
项目:Equella    文件:TaskSortSection.java   
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());
        }
    };
}
项目:cassandra-fhir-index    文件:KeyMapper.java   
/**
 * 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));
                }
            };
        }
    });
}
项目:drftpd3    文件:LuceneEngine.java   
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();
                }
            }
    ));
}
项目:search    文件:SortableBinaryField.java   
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);
}
项目:drftpd3    文件:LuceneEngine.java   
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();
                }
            }
    ));
}
项目:stratio-cassandra    文件:ClusteringKeyMapper.java   
/**
 * 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);
        }
    })};
}
项目:NYBC    文件:ShardDoc.java   
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;
}
项目:search-core    文件:ShardFieldSortedHitQueue.java   
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;
}
项目:solr-leaning2rank    文件:RankingComponent.java   
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;
}
项目:solr-leaning2rank    文件:RankingComparatorTest.java   
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;
}
项目:drftpd3-extended    文件:LuceneEngine.java   
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();
                }
            }
    ));
}
项目:Equella    文件:SortField.java   
public SortField(String field, FieldComparatorSource fieldComparatorSource)
{
    this(field, false, Type.CUSTOM, fieldComparatorSource);
}
项目:Equella    文件:SortField.java   
public FieldComparatorSource getFieldComparatorSource()
{
    return fieldComparatorSource;
}
项目:Equella    文件:ItemIndex.java   
/**
 * 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));
}
项目:hub-jira    文件:CustomFieldMock.java   
@Override
public FieldComparatorSource getSortComparatorSource() {

    return null;
}