lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Staveley (Tom)" <>
Subject RE: MissingStringLastComparatorSource and MultiSearcher
Date Sat, 15 Jul 2006 15:10:37 GMT
Incidentally, Yonik, is the logic for flawed? I don't see how
the same comparator can be used for forward and reverse sorts for the
non-null values. 

Methinks it is broken for reverse sorts where you specify nulls to appear

I added this test to from, which confirms my
suspicions ...or confirms that I'd never get a job in QA:

public void testSortingReverseNullFirst() throws Exception {

	Hits result;

	boolean reverse = true;
	boolean nullLast = false;
	boolean nullFirst = true;

	Sort order = new Sort(Sorting.getStringSortField("data", reverse,
nullLast, nullFirst));

	result =, order);

	assertEquals("didn't get all", data.length, result.length());

	assertEquals("wrong order 2", "0", result.doc(2).get("id"));
	assertEquals("wrong order 3", "3", result.doc(3).get("id"));
	assertEquals("wrong order 4", "6", result.doc(4).get("id"));
	assertEquals("wrong order 5", "7", result.doc(5).get("id"));
	assertEquals("wrong order 6", "4", result.doc(6).get("id"));
	assertEquals("wrong order 7", "1", result.doc(7).get("id"));

-----Original Message-----
From: Yonik Seeley [] 
Sent: 14 July 2006 21:59
Subject: Re: MissingStringLastComparatorSource and MultiSearcher

On 7/14/06, Rob Staveley (Tom) <> wrote:
> I was wanting to apply this to a field, which sorts on INT.

The problem with int is that the FieldCache stores the values as an int[],
and you can't tell when a value is missing.

> Specifically I'm
> trying to achieve reverse chronological sorting on a timestamp field, 
> which stores YYMMDDHHI (i.e. resolves to 10 minutes and doesn't handle
> Missing timestamps are assumed to be "old" (i.e. should appear at the
> I could get this to sort on String and use 
> MissingStringLastComparatorSource, but would this not be less 
> efficient than sorting in INT??

String sorting takes more memory, but the speed is the same.  Local sorting
with the FieldCache for strings is done via the ordinal value (no string
compare is done, just int comparisons).

-Yonik Solr, the open-source Lucene search server

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message