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
Added support for empty field arrays in mappings #7271
Conversation
e615f8d
to
b43c2ce
Compare
@@ -248,7 +247,7 @@ public static void parseField(AbstractFieldMapper.Builder builder, String name, | |||
public static void parseMultiField(AbstractFieldMapper.Builder builder, String name, Map<String, Object> node, Mapper.TypeParser.ParserContext parserContext, String propName, Object propNode) { | |||
if (propName.equals("path")) { | |||
builder.multiFieldPathType(parsePathType(name, propNode.toString())); | |||
} else if (propName.equals("fields")) { | |||
} else if (propName.equals("fields") && propNode instanceof Map) { |
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.
I think we should not just ignore when something else than a map is provided? Maybe we could do something like:
} else if (propName.equals("fields") {
final Map<String, Object> multiFieldsPropNodes;
if (propNode instance of List && ((List<?>) propNode.isEmpty()) {
multiFieldsPropNodes = Collections.emptyMap();
} else if (propNode instanceof Map) {
multiFieldsPropNodes = (Map<String, Object>) propNode;
} else {
throw new MapperParsingException("Expected map for property [fields] on field [" + multiFieldName + "] or [" + type + "] but got a " + propNode.getClass());
}
}
@cfontes I left two comments on the PR but otherwise it looks good, especially the tests. I would be nice to fix these imports. I'm quite surprised that you mention that you use Intellij since I thought we were using Intellij's defaults (we even have an eclipse configuration to make sure we are using Intellij's import style). Or maybe you have a non-default configuration of imports in Intellij? Could you please also sign our contributor license agreement so that we can eventually merge this pull request? Thanks! |
I just learned that it is in, so it is allright for the CLA. |
Thanks for the review. I will look into fixing those and push it asap. About the imports, you are right... it's my bad, one of my other projects have a very specific rule for imports and it got into my ES project by mistake. Will fix that too. Cheers! |
Added back the IntelliJ default import settings. Since there is nothing really to do in Thanks! |
Merged, thanks! |
Fix for #6133, added the ability to send empty arrays as part of an index mapping json. For single and multi field properties objects
Sorry for the import changes, IntelliJ doesn't like eclipse imports and fights it like the devil.
If the test are in a non standard format please advise. I just find them easier to read like this.