Skip to content
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

Fix a type check that is always false #27726

Merged
merged 1 commit into from
Mar 28, 2018
Merged

Fix a type check that is always false #27726

merged 1 commit into from
Mar 28, 2018

Conversation

rneatherway
Copy link
Contributor

DocumentParser: The checks for Text and Keyword were masked by the
earlier check for String, which they are child classes of. I changed
the order to have the more specific checks first so that they are all
now possible.

Separated for more review from #27706

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@@ -618,16 +618,16 @@ private static void parseNullValue(ParseContext context, ObjectMapper parentMapp

private static Mapper.Builder<?,?> createBuilderFromFieldType(final ParseContext context, MappedFieldType fieldType, String currentFieldName) {
Mapper.Builder builder = null;
if (fieldType instanceof StringFieldType) {
Copy link
Member

@cbuescher cbuescher Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving my original comment from #27706 over here.
This change also makes sense to me, but I'd like @jpountz or @jimczi to also comment on this because fixing it might change the current behaviour in unexpected ways or there might be other side effects to consider.
It looks like we never reached the TextFieldType-case in the past and I'm wondering under which circumstance we might have wanted to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping, any chance someone would be able to take a look at this one?

@cbuescher cbuescher self-assigned this Jan 23, 2018
@rneatherway
Copy link
Contributor Author

I've resolved the conflicts on this one.

@cbuescher
Copy link
Member

@rneatherway thanks a lot, I started looking into this again. The change itself makes total sense but as I mentioned earlier we will need to get a better overview about its effects on currently existing mappings. Unfortunately that hasn't happend yet, thats why this is still in the review queue.

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cbuescher
Copy link
Member

@jpountz I think we briefly talked about this one and the fix makes sense, but we were not sure about what this means for backwards compatibility. Maybe we should fix it at least in master? Adding you and //cc @elastic/es-search-aggs in case somebody else has an opinion on this.

@cbuescher cbuescher added :Search Foundations/Mapping Index mappings, including merging and defining field types >bug v7.0.0 labels Mar 8, 2018
@jpountz
Copy link
Contributor

jpountz commented Mar 26, 2018

This is a good fix indeed. It is due to the fact that we used the same name for a parent class of the text and keyword field types as for the legacy string field, which was probably not wise. In 6.x and 7.x we can just remove the check for StringFieldType entirely since string fields are not supported anymore. There is no concern to have regarding backward compatibility since this code is only used on the first time that a field is seen and then stores the result, we do not need to make sure to do consistent decisions later on.

@cbuescher
Copy link
Member

@rneatherway sorry for the long delay here, seems like we're all set. Could you remove the whole "instanceof StringFieldType" check as @jpountz suggested, then we can get this into master and 6.x.

@cbuescher cbuescher added v6.3.0 and removed discuss labels Mar 27, 2018
DocumentParser: The checks for Text and Keyword were masked by the
earlier check for String, which they are child classes of. As String
field types are no longer supported, this check can be removed.
@rneatherway
Copy link
Contributor Author

Sure, amended the commit and adjusted the description.

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rneatherway thanks a lot, LGTM. Will kick of final tests and merge once they passed.

@cbuescher
Copy link
Member

@elasticmachine test this please

@cbuescher
Copy link
Member

@elasticmachine retest this please

@cbuescher cbuescher merged commit ea8e366 into elastic:master Mar 28, 2018
cbuescher pushed a commit that referenced this pull request Mar 28, 2018
DocumentParser: The checks for Text and Keyword were masked by the
earlier check for String, which they are child classes of. As String
field types are no longer supported, this check can be removed.
@cbuescher
Copy link
Member

@rneatherway its merged now, thanks again for raising this and the other issues, much appreciated.

@rneatherway rneatherway deleted the document-parser-unneeded-type-check branch March 28, 2018 09:53
@rneatherway
Copy link
Contributor Author

Glad to get it in, I know it can be a bit unclear with some of these issues exactly what the right change is.

I'll make this my final shameless plug for turning on PR integration at https://lgtm.com/projects/g/elastic/elasticsearch/ci/ :-) That way you have a chance to catch these when they are introduced and it is easier to see what the fix is from the changes that are being made at the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types v6.3.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants