From 7cb696041c30474ae16e90d5209eb9f342da1149 Mon Sep 17 00:00:00 2001 From: Gautam Worah Date: Wed, 21 Jul 2021 01:08:53 -0700 Subject: [PATCH] Category documents added in the Lucene 9.0 taxonomy index use a BDV field with a different name Using BDV fields with a different "$full_path_binary$" name ensures that the earlier "$full_path$" StringField does not have the same name as the BDV field and hence they don't violate the field type consistency check (LUCENE-9334). This commit also enables the back-compat check that was disabled earlier. --- .../java/org/apache/lucene/facet/taxonomy/directory/Consts.java | 1 + .../facet/taxonomy/directory/DirectoryTaxonomyReader.java | 2 +- .../facet/taxonomy/directory/DirectoryTaxonomyWriter.java | 2 +- .../facet/taxonomy/directory/TestBackwardsCompatibility.java | 1 - 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java index 104bfdfb862..5bc253fddae 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java @@ -21,6 +21,7 @@ import org.apache.lucene.util.BytesRef; /** @lucene.experimental */ abstract class Consts { static final String FULL = "$full_path$"; + static final String FULL_BINARY = "$full_path_binary$"; static final String FIELD_PAYLOADS = "$payloads$"; static final String PAYLOAD_PARENT = "p"; static final BytesRef PAYLOAD_PARENT_BYTES_REF = new BytesRef(PAYLOAD_PARENT); diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java index ea38d8c24d7..71d3481447b 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java @@ -335,7 +335,7 @@ public class DirectoryTaxonomyReader extends TaxonomyReader implements Accountab int readerIndex = ReaderUtil.subIndex(ordinal, indexReader.leaves()); LeafReader leafReader = indexReader.leaves().get(readerIndex).reader(); // TODO: Use LUCENE-9476 to get the bulk lookup API for extracting BinaryDocValues - BinaryDocValues values = leafReader.getBinaryDocValues(Consts.FULL); + BinaryDocValues values = leafReader.getBinaryDocValues(Consts.FULL_BINARY); FacetLabel ret; diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java index ad0c74cc2c9..53445b19fe3 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java @@ -476,7 +476,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter { String fieldPath = FacetsConfig.pathToString(categoryPath.components, categoryPath.length); fullPathField.setStringValue(fieldPath); d.add(fullPathField); - d.add(new BinaryDocValuesField(Consts.FULL, new BytesRef(fieldPath))); + d.add(new BinaryDocValuesField(Consts.FULL_BINARY, new BytesRef(fieldPath))); // Note that we do no pass an Analyzer here because the fields that are // added to the Document are untokenized or contains their own TokenStream. diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestBackwardsCompatibility.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestBackwardsCompatibility.java index 05142b8613b..76138bd2903 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestBackwardsCompatibility.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestBackwardsCompatibility.java @@ -55,7 +55,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase { // Old taxonomy index had $full_path$ field indexed only with postings, // It is not allowed to add the same field $full_path$ indexed with BinaryDocValues // for a new segment, that this test is trying to do. - @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9334") public void testCreateNewTaxonomy() throws IOException { createNewTaxonomyIndex(oldTaxonomyIndexName); }