Hi, 
I have a problem while trying to extract term vector's attributes (i.e. 
position of the terms). What I have done was: 

Terms termVector = indexReader.getTermVector(docId, fieldName);
        TermsEnum reuse = null;
        TermsEnum iterator = termVector.iterator(reuse);
        PositionIncrementAttribute attribute =  
iterator.attributes().getAttribute(PositionIncrementAttribute.class);
        BytesRef ref = null;
        while ((ref = iterator.next()) != null) {
            System.out.println(attribute.getPositionIncrement());
}


I get an Exception : 
This AttributeSource does not have the attribute 
'org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute'.

>From the API I didn't find any other way to extract the information. Could you 
>please help me? 
Thanks in advance
Best regards, Andi


ps. I have tried to open the index with Luke and the term vector's attributes 
are stored in the index. 
                                          

Reply via email to