public class OrdinalMappingAtomicReader extends FilterAtomicReader
FilterAtomicReader
for updating facets ordinal references,
based on an ordinal map. You should use this code in conjunction with merging
taxonomies - after you merge taxonomies, you receive an DirectoryTaxonomyWriter.OrdinalMap
which maps the 'old' payloads to the 'new' ones. You can use that map to
re-map the payloads which contain the facets information (ordinals) either
before or while merging the indexes.
For re-mapping the ordinals during index merge, do the following:
// merge the old taxonomy with the new one. OrdinalMap map = DirectoryTaxonomyWriter.addTaxonomies(); int[] ordmap = map.getMap(); // Add the index and re-map ordinals 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 OrdinalMappingAtomicReader(leaves.get(i).reader(), ordmap); } writer.addIndexes(new MultiReader(wrappedLeaves)); writer.commit();
FilterAtomicReader.FilterDocsAndPositionsEnum, FilterAtomicReader.FilterDocsEnum, FilterAtomicReader.FilterFields, FilterAtomicReader.FilterTerms, FilterAtomicReader.FilterTermsEnum
IndexReader.ReaderClosedListener
in
Constructor and Description |
---|
OrdinalMappingAtomicReader(AtomicReader in,
int[] ordinalMap)
Wraps an AtomicReader, mapping ordinals according to the ordinalMap.
|
OrdinalMappingAtomicReader(AtomicReader in,
int[] ordinalMap,
FacetIndexingParams indexingParams)
Wraps an AtomicReader, mapping ordinals according to the ordinalMap,
using the provided indexingParams.
|
Modifier and Type | Method and Description |
---|---|
Fields |
fields() |
Fields |
getTermVectors(int docID) |
doClose, document, docValues, getCombinedCoreAndDeletesKey, getCoreCacheKey, getFieldInfos, getLiveDocs, hasDeletions, maxDoc, normValues, numDocs, toString
docFreq, getContext, hasNorms, termDocsEnum, termPositionsEnum, terms, totalTermFreq
addReaderClosedListener, close, decRef, document, document, ensureOpen, equals, getRefCount, getTermVector, hashCode, incRef, leaves, numDeletedDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef
public OrdinalMappingAtomicReader(AtomicReader in, int[] ordinalMap)
OrdinalMappingAtomicReader(in, ordinalMap, new DefaultFacetIndexingParams())
public OrdinalMappingAtomicReader(AtomicReader in, int[] ordinalMap, FacetIndexingParams indexingParams)
public Fields getTermVectors(int docID) throws IOException
getTermVectors
in class FilterAtomicReader
IOException
public Fields fields() throws IOException
fields
in class FilterAtomicReader
IOException
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.