public class FacetsPayloadMigrationReader extends FilterAtomicReader
FilterAtomicReader
for migrating a facets index which encodes
category ordinals in a payload to BinaryDocValues
. To migrate the index,
you should build a mapping from a field (String) to term (Term
),
which denotes under which BinaryDocValues field to put the data encoded in the
matching term's payload. You can follow the code example below to migrate an
existing index:
// Add the index and migrate payload to DocValues on the go DirectoryReader reader = DirectoryReader.open(oldDir); IndexWriterConfig conf = new IndexWriterConfig(VER, ANALYZER); IndexWriter writer = new IndexWriter(newDir, conf); List<AtomicReaderContext> leaves = reader.leaves(); AtomicReader wrappedLeaves[] = new AtomicReader[leaves.size()]; for (int i = 0; i < leaves.size(); i++) { wrappedLeaves[i] = new FacetPayloadMigrationReader(leaves.get(i).reader(), fieldTerms); } writer.addIndexes(new MultiReader(wrappedLeaves)); writer.commit();
NOTE: to build the field-to-term map you can use
buildFieldTermsMap(Directory, FacetIndexingParams)
, as long as the
index to migrate contains the ordinals payload under
PAYLOAD_TERM_TEXT
.
FilterAtomicReader.FilterDocsAndPositionsEnum, FilterAtomicReader.FilterDocsEnum, FilterAtomicReader.FilterFields, FilterAtomicReader.FilterTerms, FilterAtomicReader.FilterTermsEnum
IndexReader.ReaderClosedListener
Modifier and Type | Field and Description |
---|---|
static String |
PAYLOAD_TERM_TEXT
The
Term text of the ordinals payload. |
in
Constructor and Description |
---|
FacetsPayloadMigrationReader(AtomicReader in,
Map<String,Term> fieldTerms)
Wraps an
AtomicReader and migrates the payload to BinaryDocValues
fields by using the given mapping. |
Modifier and Type | Method and Description |
---|---|
static Map<String,Term> |
buildFieldTermsMap(Directory dir,
FacetIndexingParams fip)
A utility method for building the field-to-Term map, given the
FacetIndexingParams and the directory of the index to migrate. |
BinaryDocValues |
getBinaryDocValues(String field) |
FieldInfos |
getFieldInfos() |
doClose, document, fields, getLiveDocs, getNormValues, getNumericDocValues, getSortedDocValues, getSortedSetDocValues, getTermVectors, maxDoc, numDocs, toString
docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, hasNorms, termDocsEnum, termPositionsEnum, terms, totalTermFreq
addReaderClosedListener, close, decRef, document, document, ensureOpen, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef
public static final String PAYLOAD_TERM_TEXT
Term
text of the ordinals payload.public FacetsPayloadMigrationReader(AtomicReader in, Map<String,Term> fieldTerms)
AtomicReader
and migrates the payload to BinaryDocValues
fields by using the given mapping.public static Map<String,Term> buildFieldTermsMap(Directory dir, FacetIndexingParams fip) throws IOException
FacetIndexingParams
and the directory of the index to migrate. The
map that will be built will correspond to partitions as well as multiple
CategoryListParams
.
NOTE: since CategoryListParams
no longer define a
Term
, this method assumes that the term used by the different
CategoryListParams
is PAYLOAD_TERM_TEXT
. If this is not
the case, then you should build the map yourself, using the terms in your
index.
IOException
public BinaryDocValues getBinaryDocValues(String field) throws IOException
getBinaryDocValues
in class FilterAtomicReader
IOException
public FieldInfos getFieldInfos()
getFieldInfos
in class FilterAtomicReader
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.