You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by aurora <au...@gmail.com> on 2005/02/17 07:33:57 UTC

bookkeeping documents cause problem in Sort

I understand that unlike relational database, Lucene is flexible in having  
documents with different set of fields. My index has documents with a date  
and content field. There are also a few book keeping documents that does  
not have the date field. Things work well except in one case:

   Sort sort = Sort('date');
   searcher.search(query, sort);

In this case an exception is thrown:

   java.lang.RuntimeException: field "date" does not appear to be indexed

It does not make sense to sort by 'date' when the document does not has  
'date'. On the other hand I don't expect the search() to return any book  
keeping documents at all since the current look for fields not in those  
documents. Is this an implementation issue or is there any inherent reason  
all document need to have the 'date' field if it is sorted?


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


Re: bookkeeping documents cause problem in Sort

Posted by aurora <au...@gmail.com>.
I found the answer. FieldCacheImpl is trying to look for a sample of the  
term to be sorted to determine the sort type. It run into problem in a  
specical case when the is only a few book keeping documents but no actual  
document with a date term.

I don't seem to remember a problem when the index is completely empty.  
There is probably code to check for empty index but it failed when the is  
actually some documents but they don't have the field to be sorted.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/


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