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.
This commit is contained in:
Gautam Worah 2021-07-21 01:08:53 -07:00 committed by Mike McCandless
parent ba417b593f
commit 7cb696041c
4 changed files with 3 additions and 3 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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.

View File

@ -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);
}