You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Varun Thacker <va...@gmail.com> on 2013/04/02 10:08:22 UTC

How to consume DocTermOrds for MultiValuedFields

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/