lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Varun Thacker <varunthacker1...@gmail.com>
Subject How to consume DocTermOrds for MultiValuedFields
Date Tue, 02 Apr 2013 08:08:22 GMT
final DocTermOrds docTermOrds =
FieldCache.DEFAULT.getDocTermOrds(atomicReader, multiValuedField);
final TermsEnum termsEnum = docTermOrds.getOrdTermsEnum(atomicReader);
DocTermOrds.TermOrdsIterator reuse = docTermOrds.lookup(doc, reuse);

int[] buffer = new int[5];
StringBuilder indexedFieldValue = new StringBuilder();

  do {
    int chunk = reuse.read(buffer);
    for (int idx = 0; idx < chunk; idx++) {
      int key = buffer[idx];
      termsEnum.seekExact((long) key);
      String fieldValue = termsEnum.term().utf8ToString();
      indexedFieldValue.append(fieldValue);
    }
    //Match indexedFieldValue here
  } while((chunk >= buffer.length));


This is how I am am consuming DocTermOrds.

Doing this gives me all the unique tokens across all the values in the
multiValuedField for that document.

How can I get each of the values in the field individually? Is there any
other cache impl. where I can

-- 


Regards,
Varun Thacker
http://www.vthacker.in/

Mime
View raw message