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

Add implementation of multi_match similar to simple_query_string. #71

Merged
merged 3 commits into from
Jun 21, 2022

Conversation

Yury-Fridlyand
Copy link

@Yury-Fridlyand Yury-Fridlyand commented Jun 15, 2022

Signed-off-by: Yury Fridlyand [email protected]

Description

See also #66.

Issues Resolved

opensearch-project#188

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • 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.

@Yury-Fridlyand Yury-Fridlyand requested a review from a team June 15, 2022 18:37
@codecov
Copy link

codecov bot commented Jun 15, 2022

Codecov Report

Merging #71 (5867c23) into integ-multi_match-#188 (d81ef73) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@                     Coverage Diff                      @@
##             integ-multi_match-#188      #71      +/-   ##
============================================================
+ Coverage                     97.69%   97.71%   +0.01%     
- Complexity                     2777     2801      +24     
============================================================
  Files                           269      270       +1     
  Lines                          6859     6912      +53     
  Branches                        437      439       +2     
============================================================
+ Hits                           6701     6754      +53     
  Misses                          157      157              
  Partials                          1        1              
Flag Coverage Δ
sql-engine 97.71% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
...arch/storage/script/filter/FilterQueryBuilder.java 100.00% <ø> (ø)
...c/main/java/org/opensearch/sql/expression/DSL.java 100.00% <100.00%> (ø)
...h/sql/expression/function/BuiltinFunctionName.java 100.00% <100.00%> (ø)
...h/sql/expression/function/OpenSearchFunctions.java 100.00% <100.00%> (ø)
...cript/filter/lucene/relevance/MultiMatchQuery.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d81ef73...5867c23. Read the comment docs.

: MATCH
| MATCH_PHRASE
;

multiFieldRelevanceFunctionName
: SIMPLE_QUERY_STRING
Copy link
Author

Choose a reason for hiding this comment

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

Typo. Would be fixed by merge.

*/

@Test
public void test1() throws IOException {

Choose a reason for hiding this comment

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

test1 is not a good name for the test

+ " WHERE multi_match(['Tags'], 'taste')";
var result1 = new JSONObject(executeQuery(query1, "jdbc"));
String query2 = "SELECT count(*) FROM " + TEST_INDEX_BEER
+ " WHERE multi_match(['T*'], 'taste')";

Choose a reason for hiding this comment

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

are there other variations of the wildcard we should consider? '*te' - for example?

+ "minimum_should_match = '2<-25% 9<-3', prefix_length = 7, tie_breaker = 0.3,"
+ "type = most_fields, slop = 2, zero_terms_query = 'ALL');";
var result = new JSONObject(executeQuery(query, "jdbc"));
assertNotEquals(0, result.getInt("total"));

Choose a reason for hiding this comment

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

I'd prefer to see an explicit answer (like assetEquals(2, ...).

msg);
}

// TODO multi_match tests:

Choose a reason for hiding this comment

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

TODO?

void multi_match() {
FunctionExpression expr = dsl.multi_match(fields, query);
assertEquals(String.format("multi_match(fields=%s, query=%s)",
fields.getValue().toString(), query.getValue().toString()),

Choose a reason for hiding this comment

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

There's no need to call toString in argument to String.format.

It will be called automatically -- https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html

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.

5 participants