lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Szymon Sutek <>
Subject Unable to retrieve OffsetTermVector for given term using Apache Lucene 6
Date Fri, 02 Dec 2016 09:08:42 GMT
Hello, I am trying to index a txt file and then retrieve it's terms offset
positions. Unfortunately I can only get only one offset information per
term, not all of it(if it occured more than once while indexing) Here are
most important parts of the code:

FieldType used while indexing.

private FieldType getFieldType(){
    FieldType fieldType = new FieldType();


    return fieldType;

After succesfully creating index, I am using indexReader to read terms.
and iterate through all of them but I have no idea how to collect
theirs offsets.

In earlier versions I would cast to needed vector from TermVector and
get offset List for a concrete term value. Now I stuck on this part of

Terms terms =  indexReader.getTermVector(0,"text");
TermsEnum iterator  = terms.iterator();

BytesRef byteRef = null;

while((byteRef = != null) {
    String term = byteRef.utf8ToString();
    if (p.matcher(term).matches())
        searchResult.put(1, term);

    System.out.println("[S]:" + term);

I would be grateful for any help!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message