Skip to content

Commit

Permalink
Always write doc_values param to mapping for wildcard field
Browse files Browse the repository at this point in the history
I made a mistake making this parameter default to false. In 3.0,
I would like to switch the default to true. An index upgraded from
2.x with the default (false) value should specifically emit the
value to avoid implicitly picking up the new default (true).

Signed-off-by: Michael Froh <[email protected]>
  • Loading branch information
msfroh committed Jan 11, 2025
1 parent fccd6c5 commit 0d2ee6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static final class Builder extends ParametrizedFieldMapper.Builder {
);
private final Parameter<String> normalizer = Parameter.stringParam("normalizer", false, m -> toType(m).normalizerName, "default");
private final Parameter<Map<String, String>> meta = Parameter.metaParam();
private final Parameter<Boolean> hasDocValues = Parameter.docValuesParam(m -> toType(m).hasDocValues, false);
private final Parameter<Boolean> hasDocValues = Parameter.docValuesParam(m -> toType(m).hasDocValues, false).alwaysSerialize();
private final IndexAnalyzers indexAnalyzers;

public Builder(String name, IndexAnalyzers indexAnalyzers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()));
}
Expand Down

0 comments on commit 0d2ee6a

Please sign in to comment.