lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Tschumy <b...@otherwise.com>
Subject Strange sort error
Date Mon, 11 Apr 2005 19:27:57 GMT
In my application, by default I display all documents that are in the  
index.  I sort them either using a "time modified" or "time created".   
If I have a newly created empty index, I find I get an error if I sort  
by "time modified" but not "time created".  In either case there are  
actually no documents that match my query so in reality there is  
nothing to sort.

Here is my query:

query = new TermQuery(new Term(MyIndexer.CREATOR_KEY,  
MyIndexer.PARSNIPS_VAL));
String fieldName = sortType == Parsnips.SORT_BY_MODIFIED ?  
MyIndexer.MODIFIED_KEY : MyIndexer.CREATED_KEY;
Sort sorter = new Sort(new SortField(fieldName, SortField.STRING,  
true));
hits = searcher.search(query, sorter);

The error I'm getting when using MyIndexer.MODIFIED_KEY as the sort  
field is:

java.lang.RuntimeException: no terms in field modified
         at  
org.apache.lucene.search.FieldCacheImpl.getStringIndex(FieldCacheImpl.ja 
va:256)
         at  
org.apache.lucene.search.FieldSortedHitQueue.comparatorString(FieldSorte 
dHitQueue.java:265)
         at  
org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator(FieldSo 
rtedHitQueue.java:180)
         at  
org.apache.lucene.search.FieldSortedHitQueue.<init>(FieldSortedHitQueue. 
java:58)
         at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:122)
         at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:64)
         at org.apache.lucene.search.Hits.<init>(Hits.java:51)
         at org.apache.lucene.search.Searcher.search(Searcher.java:41)
         at com.otherwise.parsnips.MySearcher.search(MySearcher.java:170)
         at com.otherwise.parsnips.MySearcher.search(MySearcher.java:149)
         at com.otherwise.parsnips.Parsnips.<init>(Parsnips.java:163)
         at com.otherwise.parsnips.Parsnips.main(Parsnips.java:1205)

I can't understand why I would be getting this for one sort field but  
not the other given there are 0 hits anyway in a newly created index.   
Anyone have any thoughts?  I am using Lucene 1.4.2.

-- 
Bill Tschumy
Otherwise -- Austin, TX
http://www.otherwise.com


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


Mime
View raw message