Package org.apache.lucene.facet.taxonomy
Class OrdinalMappingLeafReader
java.lang.Object
org.apache.lucene.index.IndexReader
org.apache.lucene.index.LeafReader
org.apache.lucene.index.FilterLeafReader
org.apache.lucene.facet.taxonomy.OrdinalMappingLeafReader
- All Implemented Interfaces:
Closeable,AutoCloseable
A
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();
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.index.FilterLeafReader
FilterLeafReader.FilterFields, FilterLeafReader.FilterPostingsEnum, FilterLeafReader.FilterTerms, FilterLeafReader.FilterTermsEnumNested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener -
Field Summary
Fields inherited from class org.apache.lucene.index.FilterLeafReader
in -
Constructor Summary
ConstructorsConstructorDescriptionOrdinalMappingLeafReader(LeafReader in, int[] ordinalMap, FacetsConfig srcConfig) Wraps an LeafReader, mapping ordinals according to the ordinalMap, using the providedFacetsConfigwhich was used to build the wrapped reader. -
Method Summary
Methods inherited from class org.apache.lucene.index.FilterLeafReader
checkIntegrity, doClose, getBinaryDocValues, getByteVectorValues, getDelegate, getDocValuesSkipper, getFieldInfos, getFloatVectorValues, getLiveDocs, getMetaData, getNormValues, getNumericDocValues, getPointValues, getSortedDocValues, getSortedSetDocValues, maxDoc, numDocs, searchNearestVectors, searchNearestVectors, storedFields, terms, termVectors, toString, unwrapMethods inherited from class org.apache.lucene.index.LeafReader
docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, postings, postings, searchNearestVectors, searchNearestVectors, totalTermFreqMethods inherited from class org.apache.lucene.index.IndexReader
close, decRef, ensureOpen, equals, getRefCount, hasDeletions, hashCode, incRef, leaves, notifyReaderClosedListeners, numDeletedDocs, registerParentReader, tryIncRef
-
Constructor Details
-
OrdinalMappingLeafReader
Wraps an LeafReader, mapping ordinals according to the ordinalMap, using the providedFacetsConfigwhich was used to build the wrapped reader.
-
-
Method Details
-
getSortedNumericDocValues
- Overrides:
getSortedNumericDocValuesin classFilterLeafReader- Throws:
IOException
-
getCoreCacheHelper
- Specified by:
getCoreCacheHelperin classLeafReader
-
getReaderCacheHelper
- Specified by:
getReaderCacheHelperin classIndexReader
-