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

[DRAFT] Remove builder instance from TextFieldMapper #1

Draft
wants to merge 2 commits into
base: 2.5
Choose a base branch
from

Conversation

soosinha
Copy link
Owner

@soosinha soosinha commented Apr 11, 2023

[DO NOT MERGE]

Description

[Describe what this change achieves]

Issues Resolved

opensearch-project#7001

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions
Copy link

Gradle Check (Jenkins) Run Completed with:

  • RESULT: null ❌
  • URL:
  • CommitID: c5456e3
    Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green.
    Is the failure a flaky test unrelated to your change?

@@ -1165,28 +1182,4 @@ public static Query createPhrasePrefixQuery(
return spanQuery.build();
}

@Override
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {

Choose a reason for hiding this comment

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

how will toXContent work as you have removed this method?

Choose a reason for hiding this comment

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

was reading through the code, looks like doXContentBody in ParametrizedFieldMapper might be sufficient as it is iterating over all the params. Trying to understand why Builder has been retained in the first place if it is not access from anywhere except when doXContentBody is called which there is no need to override.

Copy link
Owner Author

@soosinha soosinha Apr 12, 2023

Choose a reason for hiding this comment

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

Yes, the method doXContentBody in ParametrizedFieldMapper is iterating over all the params. So the serialized object has all the fields. But when I removed the doXContentBody method from TextFieldMapper the test testBWCSerialization failed. The failure occurred because the sequence of keys in the json string was different.
Expected:

{
    "_doc": {
        "properties": {
            "field": {
                "type": "text",
                "fields": {
                    "subfield": {
                        "type": "long"
                    }
                },
                "fielddata": true
            }
        }
    }
}

Actual

{
    "_doc": {
        "properties": {
            "field": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "subfield": {
                        "type": "long"
                    }
                }
            }
        }
    }
}

Normally in a json the order of keys should not matter but the serialized json string changes in this case and there might be some dependencies on this.
So I will add back the doXContentBody method but will call the getMergeBuilder() method to get the builder rather using the builder instance in the TextFieldMapper

Choose a reason for hiding this comment

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

but as per existing comment in the code and this test, can you check the history, why we might have to retain the order. Which BWC is this and how it can fail in prod.

Copy link
Owner Author

Choose a reason for hiding this comment

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

There is some assertion logic in MapperService where if the index mapping versions are the same then the serialized form of the mappings should also be identical. This is where the order of the fields is important to ensure BWC with old serialization.

@github-actions
Copy link

Gradle Check (Jenkins) Run Completed with:

  • RESULT: null ❌
  • URL:
  • CommitID: 51236ef
    Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green.
    Is the failure a flaky test unrelated to your change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants