Fix for text functions with non-text filter condition#21882
Fix for text functions with non-text filter condition#21882nssuresh2007 wants to merge 1 commit into
Conversation
Signed-off-by: Suresh N S <nssuresh@amazon.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21882 +/- ##
============================================
+ Coverage 73.36% 73.46% +0.10%
- Complexity 75430 75487 +57
============================================
Files 6034 6034
Lines 342604 342604
Branches 49279 49279
============================================
+ Hits 251357 251704 +347
+ Misses 71220 70873 -347
Partials 20027 20027 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Reject text-relevance functions when applied to non-text/non-keyword fields, with a clear error at planning time.
Problem
query_string(['severityNumber'], 'severityNumber:>15') on a long field was being routed to Lucene, even though Lucene's QUERY_STRING capability is only declared for text and keyword types. The multi-field path in OpenSearchFilterRule extracted literal field names but never validated their types against what text-relevance functions support — leaving the user with a generic "no backend can evaluate" error downstream (or worse, a wrong result).
Fix
Added a type check in OpenSearchFilterRule.resolveViableBackends: for any text-relevance function with explicit fields=[...], validate each resolved field is text or keyword. If not, throw
IllegalArgumentExceptionnaming the function, field, and mapping type, plus a hint to use a typed comparison. Unknown fields still fall through to existing behavior.Example error:
Out of scope
Check List
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.