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

Allow plugins outside core package to access and override some function of FieldMapper #17575

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bzhangam
Copy link

Description

Allow plugin out side core package to access some functions and fields of the FieldMapper.
Allow plugin to override the merge function of the FieldMapper.

Related Issues

This is needed to support this PR for this feature.

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

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.

@@ -69,7 +69,7 @@ public TermBasedFieldType(
/** Returns the indexed value used to construct search "values".
* This method is used for the default implementations of most
* query factory methods such as {@link #termQuery}. */
protected BytesRef indexedValueForSearch(Object value) {
public BytesRef indexedValueForSearch(Object value) {
Copy link
Author

Choose a reason for hiding this comment

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

This change relax the access to this function but all its subclasses override it with protected access modifier and we also need to change them as public. I have updated all subclasses in core. But if there is any plugin extending it we also need to update the plugin accordingly. Not sure how should we communicate change like this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not clear to me why these need to be changed from protected to public.

Subclasses can still override protected methods, even it they're defined in a plugin.

Copy link
Author

Choose a reason for hiding this comment

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

We want to make it public to allow plugin to invoke it through a field type not override it. Since we want to delegate the query work to the delegate field type and in plugin we cannot invoke the protected function even we are in the subclass. Check this code change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it -- I think you would need SemanticFieldMapper to extend TermBasedFieldMapper in order to have access to the protected method. I wonder if that would make sense? It does look like you want your SemanticFieldMapper to have term-based behavior, but be decoupled from the specifics of which term-based field type is being wrapped.

Copy link
Contributor

❌ Gradle check result for 1cc9d6b: FAILURE

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