List of usage examples for org.apache.lucene.search FieldComparator.TermValComparator FieldComparator.TermValComparator
public TermValComparator(int numHits, String field, boolean sortMissingLast)
From source file:com.stratio.cassandra.lucene.key.KeyMapper.java
License:Apache License
/** * Returns a Lucene {@link SortField} to sort documents by primary key according to Cassandra's natural order. * * @return the sort field/*from w ww .j av a 2 s. co m*/ */ 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)); } }; } }); }
From source file:com.stratio.cassandra.lucene.key.PartitionMapper.java
License:Apache License
/** * Returns a Lucene {@link SortField} for sorting documents/rows according to the partition key. * * @return a sort field for sorting by partition key *///w w w .j a v a2 s . com 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); } }; } }); }