Module org.apache.lucene.facet
Class ReindexingEnrichedDirectoryTaxonomyWriter
java.lang.Object
org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter
org.apache.lucene.facet.taxonomy.directory.ReindexingEnrichedDirectoryTaxonomyWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,TaxonomyWriter
,TwoPhaseCommit
Use this
TaxonomyWriter
to append arbitrary fields to
the ordinal documents in the taxonomy. To update the custom data added to the docs, it is
required to reindexWithNewOrdinalData(BiConsumer)
.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter
DirectoryTaxonomyWriter.DiskOrdinalMap, DirectoryTaxonomyWriter.MemoryOrdinalMap, DirectoryTaxonomyWriter.OrdinalMap
-
Field Summary
FieldsFields inherited from class org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter
INDEX_EPOCH
-
Constructor Summary
ConstructorsConstructorDescriptionReindexingEnrichedDirectoryTaxonomyWriter
(Directory d, BiConsumer<FacetLabel, Document> ordinalDataAppender) Create a taxonomy writer that will allow editing the ordinal docs before indexing them. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
enrichOrdinalDocument
(Document d, FacetLabel categoryPath) Add fields specified by theordinalDataAppender
to the providedDocument
.private List
<FacetLabel> Make a list of all labels in the taxonomy.void
reindexWithNewOrdinalData
(BiConsumer<FacetLabel, Document> ordinalDataAppender) Delete the existing taxonomy index and recreate it using new ordinal data.Methods inherited from class org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter
addCategory, addTaxonomy, close, closeResources, commit, createIndexWriterConfig, defaultTaxonomyWriterCache, deleteAll, ensureOpen, findCategory, getCache, getDirectory, getInternalIndexWriter, getLiveCommitData, getParent, getSize, getTaxonomyEpoch, openIndexWriter, prepareCommit, replaceTaxonomy, rollback, setCacheMissesUntilFill, setLiveCommitData, useNumericDocValuesForOrdinals
-
Field Details
-
ordinalDataAppender
-
-
Constructor Details
-
ReindexingEnrichedDirectoryTaxonomyWriter
public ReindexingEnrichedDirectoryTaxonomyWriter(Directory d, BiConsumer<FacetLabel, Document> ordinalDataAppender) throws IOExceptionCreate a taxonomy writer that will allow editing the ordinal docs before indexing them.- Throws:
IOException
-
-
Method Details
-
enrichOrdinalDocument
Add fields specified by theordinalDataAppender
to the providedDocument
.- Overrides:
enrichOrdinalDocument
in classDirectoryTaxonomyWriter
-
recordPathsInOrder
Make a list of all labels in the taxonomy. The index of each label in this list is the ordinal which corresponds to it.- Throws:
IOException
-
reindexWithNewOrdinalData
public void reindexWithNewOrdinalData(BiConsumer<FacetLabel, Document> ordinalDataAppender) throws IOExceptionDelete the existing taxonomy index and recreate it using new ordinal data. The ordinals themselves will be preserved, so the caller does not need to update references to them in the main index.- Throws:
IOException
-