public class OrdinalMappingLeafReader extends FilterLeafReader
FilterLeafReader
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' ordinals to the 'new' ones. You can use that map to
re-map the doc values 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 = new MemoryOrdinalMap(); DirectoryTaxonomyWriter.addTaxonomy(srcTaxoDir, map); 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<LeafReaderContext> leaves = reader.leaves(); LeafReader wrappedLeaves[] = new LeafReader[leaves.size()]; for (int i = 0; i < leaves.size(); i++) { wrappedLeaves[i] = new OrdinalMappingLeafReader(leaves.get(i).reader(), ordmap); } writer.addIndexes(new MultiReader(wrappedLeaves)); writer.commit();
FilterLeafReader.FilterFields, FilterLeafReader.FilterPostingsEnum, FilterLeafReader.FilterTerms, FilterLeafReader.FilterTermsEnum
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener
in
Constructor and Description |
---|
OrdinalMappingLeafReader(LeafReader in,
int[] ordinalMap,
FacetsConfig srcConfig)
Wraps an LeafReader, mapping ordinals according to the ordinalMap, using
the provided
FacetsConfig which was used to build the wrapped
reader. |
Modifier and Type | Method and Description |
---|---|
protected BytesRef |
encode(IntsRef ordinals)
Expert: encodes category ordinals into a BytesRef.
|
BinaryDocValues |
getBinaryDocValues(String field) |
IndexReader.CacheHelper |
getCoreCacheHelper() |
protected OrdinalsReader |
getOrdinalsReader(String field)
Expert: override in case you used custom encoding for the categories under
this field.
|
IndexReader.CacheHelper |
getReaderCacheHelper() |
checkIntegrity, doClose, document, getDelegate, getFieldInfos, getLiveDocs, getMetaData, getNormValues, getNumericDocValues, getPointValues, getSortedDocValues, getSortedNumericDocValues, getSortedSetDocValues, getTermVectors, maxDoc, numDocs, terms, toString, unwrap
docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, postings, postings, totalTermFreq
close, decRef, document, document, ensureOpen, equals, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, tryIncRef
public OrdinalMappingLeafReader(LeafReader in, int[] ordinalMap, FacetsConfig srcConfig)
FacetsConfig
which was used to build the wrapped
reader.protected BytesRef encode(IntsRef ordinals)
protected OrdinalsReader getOrdinalsReader(String field)
public BinaryDocValues getBinaryDocValues(String field) throws IOException
getBinaryDocValues
in class FilterLeafReader
IOException
public IndexReader.CacheHelper getCoreCacheHelper()
getCoreCacheHelper
in class LeafReader
public IndexReader.CacheHelper getReaderCacheHelper()
getReaderCacheHelper
in class IndexReader
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.