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

QUERY_STRING #191 #85

Merged
merged 13 commits into from
Jul 6, 2022
Merged

Conversation

forestmvey
Copy link

Description

Support query_string relevance function in SQL and PPL.

Issues Resolved

Github Issue: 191

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.

@codecov
Copy link

codecov bot commented Jul 5, 2022

Codecov Report

Merging #85 (7f6b006) into integ-query_string-#191 (058159d) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@                      Coverage Diff                      @@
##             integ-query_string-#191      #85      +/-   ##
=============================================================
+ Coverage                      97.72%   97.74%   +0.02%     
- Complexity                      2816     2848      +32     
=============================================================
  Files                            271      272       +1     
  Lines                           6934     7001      +67     
  Branches                         439      442       +3     
=============================================================
+ Hits                            6776     6843      +67     
  Misses                           157      157              
  Partials                           1        1              
Flag Coverage Δ
sql-engine 97.74% <100.00%> (+0.02%) ⬆️

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%> (ø)
...ript/filter/lucene/relevance/QueryStringQuery.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 058159d...7f6b006. Read the comment docs.

@forestmvey forestmvey requested a review from a team July 5, 2022 19:00
``query_string([field_expression+], query_expression[, option=<option_value>]*)``

The query_string function maps to the query_string query used in search engine, to return the documents that match a provided text, number, date or boolean value with a given field or fields.
The **^** lets you *boost* certain fields. Boosts are multipliers that weigh matches in one field more heavily than matches in other fields. The syntax allows to specify the fields in double quotes, single quotes, in backtick or even without any wrap. All fields search using star ``"*"`` is also available (star symbol should be wrapped). The weight is optional and should be specified using after the field name, it could be delimeted by the `caret` character or by whitespace. Please, refer to examples below:

Choose a reason for hiding this comment

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

should be specified using after the field name

using is unnecessary, I think.

Copy link
Author

Choose a reason for hiding this comment

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

+ "tie_breaker=0.3, time_zone='Canada/Pacific', default_operator='or',"
+ "fuzzy_transpositions = false, lenient = true, fuzzy_max_expansions = 25,"
+ "minimum_should_match = '2<-25% 9<-3', fuzzy_prefix_length = 7);";
var result = new JSONObject(executeQuery(query, "jdbc"));

Choose a reason for hiding this comment

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

There's a method executeJdbcRequest that simplifies this.

Copy link
Author

Choose a reason for hiding this comment

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


String query3 = "SELECT Id FROM " + TEST_INDEX_BEER
+ " WHERE query_string(['*Date'], '2015-01-29');";
var result3 = new JSONObject(executeQuery(query3, "jdbc"));

Choose a reason for hiding this comment

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

Use executeJdbcRequest to simplify this.

Copy link
Author

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Another place for executeJdbcRequest

Copy link
Author

Choose a reason for hiding this comment

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

@forestmvey forestmvey merged commit c68aecf into integ-query_string-#191 Jul 6, 2022
@forestmvey forestmvey deleted the dev-query_string-#191 branch July 6, 2022 20:53
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.

4 participants