Skip to content

Add FilterFieldType#17627

Merged
msfroh merged 7 commits intoopensearch-project:mainfrom
msfroh:filter_field_type
Apr 1, 2025
Merged

Add FilterFieldType#17627
msfroh merged 7 commits intoopensearch-project:mainfrom
msfroh:filter_field_type

Conversation

@msfroh
Copy link
Copy Markdown
Contributor

@msfroh msfroh commented Mar 18, 2025

Description

This class allows developers (in core or plugins) to wrap an existing field type, delegating all behavior by default, overriding specific methods as needed.

See linked issue for more details.

Related Issues

Resolves #17624

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.

@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 5180b1a: 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?

@kkewwei
Copy link
Copy Markdown
Contributor

kkewwei commented Mar 19, 2025

It make sense to me. But it seems not delegate all methods, such as fielddataBuilder. Also it seems don't solve the problem mentioned in #17575, it need the indexedValueForSearch, only if we also support FilterTermBasedFieldType?

@bzhangam
Copy link
Copy Markdown
Contributor

indexedValueForSearch

indexedValueForSearch will not be directly invoked to process query. It will be invoked through function like termQuery. Since we delegate the termQuery it will use the implementation of indexedValueForSearch of the delegate.

@msfroh
Copy link
Copy Markdown
Contributor Author

msfroh commented Mar 20, 2025

It make sense to me. But it seems not delegate all methods, such as fielddataBuilder. Also it seems don't solve the problem mentioned in #17575, it need the indexedValueForSearch, only if we also support FilterTermBasedFieldType?

In #17575, it doesn't actually need indexedValueForSearch, since that's internal to the implementation of the delegated field type (since that's a helper used by the various *Query methods).

You're absolutely right about fielddataBuilder -- not sure how I missed that, since I tried overriding all methods from MappedFieldType. I intentionally avoided implementing typeName(), because I believe that the filtered field type should have its own type name.

I'll add a unit test that uses reflection to enforce overrides of all methods to catch mistakes if anyone adds more methods to MappedFieldType.

@github-actions
Copy link
Copy Markdown
Contributor

✅ Gradle check result for 3c8423a: SUCCESS

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 0% with 53 lines in your changes missing coverage. Please review.

Project coverage is 72.36%. Comparing base (f4b8393) to head (2b86bd7).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...a/org/opensearch/index/mapper/FilterFieldType.java 0.00% 52 Missing ⚠️
...a/org/opensearch/index/mapper/MappedFieldType.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17627      +/-   ##
============================================
- Coverage     72.41%   72.36%   -0.05%     
+ Complexity    65880    65868      -12     
============================================
  Files          5326     5327       +1     
  Lines        305548   305601      +53     
  Branches      44322    44322              
============================================
- Hits         221258   221155     -103     
- Misses        66101    66359     +258     
+ Partials      18189    18087     -102     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

❕ Gradle check result for 6a83731: UNSTABLE

  • TEST FAILURES:
      1 org.opensearch.snapshots.DedicatedClusterSnapshotRestoreIT.testSnapshotWithStuckNode

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

msfroh added 4 commits March 26, 2025 15:58
This class allows developers (in core or plugins) to wrap an existing
field type, delegating all behavior by default, overriding specific
methods as needed.

Signed-off-by: Michael Froh <froh@amazon.com>
Signed-off-by: Michael Froh <froh@amazon.com>
After thinking about it some more, the type parameter doesn't really
give us anything.

Signed-off-by: Michael Froh <froh@amazon.com>
Signed-off-by: Michael Froh <froh@amazon.com>
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 36ee328:

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?

Signed-off-by: Michael Froh <froh@amazon.com>
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 3759210:

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?

@github-actions
Copy link
Copy Markdown
Contributor

✅ Gradle check result for 3759210: SUCCESS

msfroh added 2 commits March 28, 2025 11:09
Signed-off-by: Michael Froh <froh@amazon.com>
Signed-off-by: Michael Froh <froh@amazon.com>
@github-actions
Copy link
Copy Markdown
Contributor

❕ Gradle check result for 2b86bd7: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement or improvement to existing feature or request Search:Query Capabilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Make it easier to wrap existing field types

5 participants