-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Convert KeywordFieldMapper to parametrized form #60645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert KeywordFieldMapper to parametrized form #60645
Conversation
Pinging @elastic/es-search (:Search/Mapping) |
Map<String, Object> fieldTypeConfig = dynamicTemplate.mappingForName("__dummy__", defaultDynamicType); | ||
fieldTypeConfig.remove("type"); | ||
String templateName = "__dynamic__" + dynamicTemplate.name(); | ||
Map<String, Object> fieldTypeConfig = dynamicTemplate.mappingForName(templateName, defaultDynamicType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This yields better error messages for dynamic mappings, including the name of the dynamic mapping itself and the type of the dynamically created field.
MapperParsingException e = expectThrows(MapperParsingException.class, | ||
() -> TypeParsers.parseField(builder, builder.name, mapping, parserContext)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KeywordFieldMapper.Builder doesn't match the signature of parseField
anymore (because we don't actually use it in parsing), so I've adjusted these to directly test the parseMeta
method.
@elasticmachine run elasticsearch-ci/docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romseygeek Thanks, the PR overall LGTM, I just left a couple of comments.
server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java
Show resolved
Hide resolved
@@ -92,149 +83,134 @@ public KeywordField(String field, BytesRef term) { | |||
|
|||
} | |||
|
|||
public static class Builder extends FieldMapper.Builder<Builder> { | |||
private static KeywordFieldMapper toType(FieldMapper in) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 69-71 and 80-82 seem to be unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ they are, will remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @romseygeek, the PR LGTM
@elasticmachine update branch |
This makes KeywordFieldMapper extend ParametrizedFieldMapper, with explicitly defined parameters. In addition, we add a new option to Parameter, restrictedStringParam, which accepts a restricted set of string options.
This makes KeywordFieldMapper extend ParametrizedFieldMapper, with explicitly
defined parameters.
In addition, we add a new option to Parameter,
restrictedStringParam
, whichaccepts a restricted set of string options.