diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java index 0ae022a726b..678f4ff9f2a 100644 --- a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java +++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java @@ -94,7 +94,6 @@ public final class FieldInfo { } private boolean checkConsistency() { - // nocommit more checks here if (!indexed) { assert !storeTermVector; assert !storePayloads; @@ -103,6 +102,9 @@ public final class FieldInfo { assert indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS; } else { assert indexOptions != null; + if (omitNorms) { + assert normType == null; + } } // Cannot store payloads unless positions are indexed: @@ -126,6 +128,7 @@ public final class FieldInfo { } if (this.omitNorms != omitNorms) { this.omitNorms = true; // if one require omitNorms at least once, it remains off for life + this.normType = null; } if (this.indexOptions != indexOptions) { // downgrade @@ -199,7 +202,7 @@ public final class FieldInfo { * @return true if this field actually has any norms. */ public boolean hasNorms() { - return indexed && !omitNorms && normType != null; + return normType != null; } /** diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java index c0085eaaf3f..3d8a72d273e 100644 --- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java +++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java @@ -278,7 +278,7 @@ public class FieldInfos implements Iterable { if (docValues != null) { fi.setDocValuesType(docValues); } - if (normType != null) { + if (!fi.omitsNorms() && normType != null) { fi.setNormValueType(normType); } } diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java b/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java index f65a8668686..d336a2518a9 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java @@ -239,7 +239,7 @@ final class SegmentMerger { } else { assert promoter != TypePromoter.getIdentityPromoter(); if (norms) { - if (fi.getNormType() != promoter.type()) { + if (fi.getNormType() != promoter.type() && !fi.omitsNorms()) { // reset the type if we got promoted fi.setNormValueType(promoter.type()); }