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

Refactor implementation of relevance queries #746

Merged

Conversation

MaxKsyunz
Copy link
Collaborator

Description

  1. Simplified function resolution for relevance query functions.
  2. Throw a SemanticCheckException from RelevanceQuery::build if a parameter is specified more than once. Combined with (1), the end user gets a much better error message.
  3. Introduced MultiFieldQuery and SingleFieldQuery. This allowed for cleaner code in derived classes.
  4. Removed duplicated code from MultiMatchQuery and QueryStringQuery. These functions now throw a SyntaxCheckException if called with insufficient number of parameters. This is in line with other query functions.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • Commits are signed per the DCO using --signoff

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.

@MaxKsyunz MaxKsyunz requested a review from a team as a code owner August 11, 2022 18:48
@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2022

Codecov Report

Merging #746 (0f13069) into main (29f1c52) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main     #746      +/-   ##
============================================
- Coverage     94.78%   94.76%   -0.03%     
- Complexity     2880     2884       +4     
============================================
  Files           286      289       +3     
  Lines          7735     7699      -36     
  Branches        565      562       -3     
============================================
- Hits           7332     7296      -36     
  Misses          349      349              
  Partials         54       54              
Flag Coverage Δ
query-workbench 62.76% <ø> (ø)
sql-engine 97.75% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...arch/sql/expression/datetime/DateTimeFunction.java 100.00% <ø> (ø)
...search/sql/expression/datetime/IntervalClause.java 100.00% <ø> (ø)
...expression/function/BuiltinFunctionRepository.java 100.00% <ø> (ø)
...ression/operator/arthmetic/ArithmeticFunction.java 100.00% <ø> (ø)
...ssion/operator/arthmetic/MathematicalFunction.java 100.00% <ø> (ø)
.../expression/operator/convert/TypeCastOperator.java 100.00% <ø> (ø)
...on/operator/predicate/BinaryPredicateOperator.java 100.00% <ø> (ø)
...g/opensearch/sql/expression/text/TextFunction.java 100.00% <ø> (ø)
...sql/expression/aggregation/AggregatorFunction.java 100.00% <100.00%> (ø)
...l/expression/function/DefaultFunctionResolver.java 100.00% <100.00%> (ø)
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

- Update QueryStringTest to check for SyntaxCheckException.
SyntaxCheckException is correct when incorrect # of parameters
See opensearch-project#604 (comment)
for reference.

- Introduce MultiFieldQuery and SingleFieldQuery base classes.

- Extract FunctionResolver interface. FunctionResolver is now
 DefaultFunctionResolver. RelevanceFunctionResolver is a simplified
 function resolver for relevance search functions.
- Removed tests from FilterQueryBuilderTest that verified exceptions
 thrown for invalid function calls.
 These scenarios are now handled by RelevanceQuery::build.

Signed-off-by: MaxKsyunz <[email protected]>
@joshuali925 joshuali925 merged commit b869b6a into opensearch-project:main Sep 7, 2022
@MaxKsyunz MaxKsyunz deleted the integ-textsearch-improvements branch February 8, 2023 17:59
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.

7 participants