You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Jon Pipitone <jp...@mshri.on.ca> on 2004/03/24 19:39:08 UTC

RuntimeException on sorted search over an empty index

Hi folks,

This might be more apt for the User list, but here goes.

I've been trying out the new sorting capabilities from the latest CVS 
build.  I'm really impressed with the performance (over a single index 
and multiple indices) and how easy it is to use.

But, I find when I do a sorted search over an emtpy index I get the 
following sort of RuntimeException:

java.lang.RuntimeException: no terms in field id
	at 
org.apache.lucene.search.IntegerSortedHitQueue$1.generateSortIndex(IntegerSortedHitQueue.java:91)
	at 
org.apache.lucene.search.IntegerSortedHitQueue$1.<init>(IntegerSortedHitQueue.java:80)
	at 
org.apache.lucene.search.IntegerSortedHitQueue.comparator(IntegerSortedHitQueue.java:77)
	at 
org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator(FieldSortedHitQueue.java:127)
	at 
org.apache.lucene.search.MultiFieldSortedHitQueue.<init>(MultiFieldSortedHitQueue.java:54)
	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:171)
	at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:102)
	at org.apache.lucene.search.Hits.<init>(Hits.java:89)
	at org.apache.lucene.search.Searcher.search(Searcher.java:79)


I get this when I use an integer sort field like so:

	Sort sort = new Sort(new SortField("id", SortField.INT));
	Directory dir = new RAMDirectory();
	(new IndexWriter(dir, new StandardAnalyzer(), true)).close();
	IndexSearcher searcher = new IndexSearcher(dir);
	Hits hits = searcher.search(query, sort);

I can't see why an exception should be being thrown here, since there 
are no records to return, and the type of sort field is explicitly 
integer (so there's no need to discover the type by inspecting an 
existing term).  I would expect to get back an empty Hits, as I would if 
I hadn't provided the sort.

Thanks,
jp


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org