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

Correct how meta-field is defined for pre 7.8 hits #57951

Merged
merged 4 commits into from
Jun 12, 2020

Conversation

mayya-sharipova
Copy link
Contributor

@mayya-sharipova mayya-sharipova commented Jun 10, 2020

We keep a static list of meta-fields: META_FIELDS_BEFORE_7_8
as it was before.
This is done to ensure the backwards compatability with pre 7.8 nodes.

Relates to #57771
Closes #57831

We keep a static list of meta-fields: META_FIELDS_BEFORE_7_8
as it was before.
This is done to ensure the backwards compatability with pre 7.8 nodes.

Closes elastic#57831
@mayya-sharipova mayya-sharipova added v7.9.0 >test Issues or PRs that are addressing/adding tests :Search/Search Search-related issues that do not fall into other categories labels Jun 10, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jun 10, 2020
}
// if a node had Size Plugin installed, _size field should also be considered a meta-field
return fieldName.equals("_size");
return META_FIELDS_BEFORE_7_8.contains(fieldName);
Copy link
Member

Choose a reason for hiding this comment

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

If I remember correctly we only use isMetadataFieldStatic in a few places now where we read from older nodes. Should we simply make the collection public and remove the static method? Or rename method to something like "isMetaFieldBefore7dot8" or something, just to improve readability in the locations where this it is actually used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbuescher Thanks for the feedback! I have removed isMetadataFieldStatic method, and made the collection public.

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.

LGTM, I left a minor nit, feel free to ignore

…nces

SearchHitsTests.testSerializationPre6_6_0 will fail
if you use different meta-fields that were before
@@ -106,7 +106,7 @@ private static DocumentField mutateDocumentField(DocumentField documentField) {
Predicate<String> excludeMetaFieldFilter) {
if (isMetafield) {
String metaField = randomValueOtherThanMany(excludeMetaFieldFilter,
() -> randomFrom(IndicesModule.getBuiltInMetadataFields()));
() -> randomFrom(MapperService.META_FIELDS_BEFORE_7DOT8));
Copy link
Member

Choose a reason for hiding this comment

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

Just as a last question: why is this necessary? I though the "old" collection of meta field names is only used when reading from "old" nodes? Why can't we use all built-in fields here since we're already on master?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbuescher I am struggling with BWC tests here, and I am not sure about the best approach.

SearchHitsTests.testSerializationPre6_6_0 tests was failing if we use IndicesModule.getBuiltInMetadataFields().

In this test we create a test SearchHit instance in 7.x and then do wire serialization to pre6_6 node and deserialization from it, and then assert that 7.x instance is equal to the deserialized instance from 6.x. The test was failing if we use IndicesModule.getBuiltInMetadataFields() and include _fied_names as a meta-field in the created test instance. As now during deserialization from pre 7.8 nodes we use META_FIELDS_BEFORE_7DOT8 to decide if a field is meta-field, we put _field_names under document fields, which will not be equal to the original created test instance, where _field_names is under meta-fields.

Probably, the best approach would be to separate how we create test instances of SearchHit between pre 7.8 nodes and after 7.8 nodes. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Are those particular tests needed on 7.x anymore? As far as I understand we'd never see a pre 6.6 node in a cluster running any 7x release at this point, 6.8 should be the last supported version? Maybe we can delete the test? I wonder if this uncovers other kinds of edge cases with the change though, so I'd prefer if we can sample "meta" fields from the "true" source (IndicesModule.getBuiltInMetadataFields()) and only fix tests where we need a specific pre-7.8 behaviour if really needed.
Mabye @javanna knows if SearchHitsTests.testSerializationPre6_6_0 can be removed since he added it way back...

Copy link
Member

Choose a reason for hiding this comment

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

#36555 I guess the test (actually two tests) can be removed from 7.x given that 7.x nodes will never talk to pre 6.6 nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@javanna Thanks, this would simplify things

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbuescher Thanks for your suggestions. I have removed *pre6_6_0 tests, and also brought back IndicesModule.getBuiltInMetadataFields() for defining meta-fields in test items.

@mayya-sharipova mayya-sharipova merged commit 8bd0147 into elastic:7.x Jun 12, 2020
@mayya-sharipova mayya-sharipova deleted the hit-text-fix branch June 12, 2020 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team >test Issues or PRs that are addressing/adding tests v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants