Hi Aviran,
The code you are calling assumes that you have indexed with TermVector support for 
offsets (and optionally positions) ie code like this:
 
doc.add(new Field("contents", content, 
               Field.Store.COMPRESS, Field.Index.TOKENIZED, 
               Field.TermVector.WITH_POSITIONS_OFFSETS));
 
If you haven't stored offsets then the getTermFreqVector method returns a 
TermFreqVector rather than the TermPositionVector subclass, hence the class cast 
exception. I should tighten up that section of code to check for this situation and 
throw an exception with a suitable message. 
 
By the way, the "getAnyTokenStream" method is coded a little more defensively and will 
silently drop back to re-analyzing (parsing) the original content if it is asked to 
get a TokenStream for a field that doesnt have offset data stored. This is probably 
the safest way to code your app and the cost of the logic which checks the field 
storage type is minimal.
 
Cheers 
Mark

                
---------------------------------
 ALL-NEW Yahoo! Messenger - all new features - even more fun!  

Reply via email to