diff --git a/server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java index 7342c6f9f23bd..721b047573a60 100644 --- a/server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java @@ -101,7 +101,7 @@ public static final class Builder extends ParametrizedFieldMapper.Builder { ); private final Parameter normalizer = Parameter.stringParam("normalizer", false, m -> toType(m).normalizerName, "default"); private final Parameter> meta = Parameter.metaParam(); - private final Parameter hasDocValues = Parameter.docValuesParam(m -> toType(m).hasDocValues, false); + private final Parameter hasDocValues = Parameter.docValuesParam(m -> toType(m).hasDocValues, false).alwaysSerialize(); private final IndexAnalyzers indexAnalyzers; public Builder(String name, IndexAnalyzers indexAnalyzers) { diff --git a/server/src/test/java/org/opensearch/index/mapper/WildcardFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/WildcardFieldMapperTests.java index a93f6b2d47e4f..b19e3687cf944 100644 --- a/server/src/test/java/org/opensearch/index/mapper/WildcardFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/WildcardFieldMapperTests.java @@ -49,6 +49,7 @@ public class WildcardFieldMapperTests extends MapperTestCase { @Override protected void minimalMapping(XContentBuilder b) throws IOException { b.field("type", "wildcard"); + b.field("doc_values", false); } @Override @@ -59,7 +60,10 @@ protected void writeFieldValue(XContentBuilder builder) throws IOException { @Override protected void registerParameters(ParameterChecker checker) throws IOException { checker.registerConflictCheck("normalizer", b -> b.field("normalizer", "lowercase")); - checker.registerConflictCheck("doc_values", b -> b.field("doc_values", true)); + checker.registerConflictCheck("doc_values", fieldMapping(this::minimalMapping), fieldMapping(xcb -> { + xcb.field("type", "wildcard"); + xcb.field("doc_values", true); + })); checker.registerConflictCheck("null_value", b -> b.field("null_value", "foo")); checker.registerUpdateCheck(b -> b.field("ignore_above", 256), m -> assertEquals(256, ((WildcardFieldMapper) m).ignoreAbove())); }