lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <markharw...@yahoo.co.uk>
Subject RE: Faster highlighting with TermPositionVectors
Date Thu, 04 Nov 2004 09:09:54 GMT
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!  
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message