Added Query Function As Query_string Function#143
Added Query Function As Query_string Function#143GabeFernandez310 merged 1 commit intointeg-add-query-functionfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## integ-add-query-function #143 +/- ##
==============================================================
+ Coverage 94.95% 95.23% +0.28%
- Complexity 3190 3395 +205
==============================================================
Files 316 330 +14
Lines 8646 9302 +656
Branches 637 691 +54
==============================================================
+ Hits 8210 8859 +649
- Misses 382 386 +4
- Partials 54 57 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
acarbonetto
left a comment
There was a problem hiding this comment.
Good job guys! Thanks for the work. Just a couple of comments
| TestsConstants.TEST_INDEX_ACCOUNT)); | ||
| Assert.assertThat(result, | ||
| containsString("query_string\":{\"query\":\"address:880 Holmes Lane")); | ||
| containsString("query_string\\\":{\\\"query\\\":\\\"address:880 Holmes Lane")); |
There was a problem hiding this comment.
There were some issues with escaped characters causing it to fail.
| @Test | ||
| public void all_fields_test() throws IOException { | ||
| String query = "SELECT * FROM " | ||
| + TEST_INDEX_BEER + " WHERE query('*:taste')"; |
There was a problem hiding this comment.
I thought the wildcard syntax doesn't work? Or does it work with just *?
There was a problem hiding this comment.
I thought so too... I thought we determined that they didn't work when we had our 1:1. I played around with it trying different combinations...
The following all seem to work when passed in as the query for query_string:
"* : taste"
"* : ?aste"
"Tags : *aste"
"Tags : Ta?te"
"Tags : Ta*te"
I tried these according to this documentation for Lucene, but it doesn't seem to follow it exactly since it also allows * and ? to be the first character of a search. Should we add tests for all of these cases as well? I can't find a specific Doc to reference for what should/shouldn't be supported in the query so I'm not really sure what other behaviour we should be testing for that we might be missing.
There was a problem hiding this comment.
I was more asking about the field name (* or Tags). It seems like those two cases are fine, but T?g* is not?
Honestly, the checks are handled by OpenSearch not us... so what additional tests are going to do is test another system. We can consider covering some of the general cases, but we do not need to be exhaustive here.
.../java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/NoFieldQuery.java
Outdated
Show resolved
Hide resolved
...arch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/QueryTest.java
Show resolved
Hide resolved
...arch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/QueryTest.java
Outdated
Show resolved
Hide resolved
sql/src/test/java/org/opensearch/sql/sql/parser/AstExpressionBuilderTest.java
Outdated
Show resolved
Hide resolved
...a/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/NoFieldQueryTest.java
Show resolved
Hide resolved
.../java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/NoFieldQuery.java
Outdated
Show resolved
Hide resolved
.../java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/NoFieldQuery.java
Outdated
Show resolved
Hide resolved
...in/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/QueryQuery.java
Show resolved
Hide resolved
.../java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/NoFieldQuery.java
Outdated
Show resolved
Hide resolved
sql/src/main/java/org/opensearch/sql/sql/parser/AstExpressionBuilder.java
Outdated
Show resolved
Hide resolved
|
Hint: |
...in/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/QueryQuery.java
Outdated
Show resolved
Hide resolved
827a0cf to
89b3e1a
Compare
d49c0d1 to
9d14975
Compare
| protected interface QueryBuilderStep<T extends QueryBuilder> extends | ||
| BiFunction<T, ExprValue, T> { | ||
| } | ||
|
|
There was a problem hiding this comment.
Formatting change not needed, and really should only be included in a review when appropriate.
| + "analyzer='keyword', operator='AND')")); | ||
| } | ||
|
|
||
|
|
| String.format("Parameter '%s' can only be specified once.", k)); | ||
| } | ||
| }); | ||
| .forEach((k, v) -> { |
There was a problem hiding this comment.
Introduced by accident when I was trying to fix checkstyle issues. Fixed in 7add05f
| queryBuildActions | ||
| .get(argNormalized))) | ||
| .apply(queryBuilder, arg.getValue().valueOf(null)); | ||
| queryBuildActions |
There was a problem hiding this comment.
Introduced by accident when I was trying to fix checkstyle issues. Fixed in 7add05f
forestmvey
left a comment
There was a problem hiding this comment.
Looks good other than some unnecessary formatting changes.
| @Test | ||
| public void all_fields_test() throws IOException { | ||
| String query = "SELECT * FROM " | ||
| + TEST_INDEX_BEER + " WHERE query('*:taste')"; |
There was a problem hiding this comment.
I was more asking about the field name (* or Tags). It seems like those two cases are fine, but T?g* is not?
Honestly, the checks are handled by OpenSearch not us... so what additional tests are going to do is test another system. We can consider covering some of the general cases, but we do not need to be exhaustive here.
docs/user/dql/functions.rst
Outdated
| ``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 query_string function maps to the query_string query used in search engine (also used by `query`_), to return the documents that match a provided text, number, date or boolean value with a given field or fields. |
There was a problem hiding this comment.
please remove, this is confusing and covered below
docs/user/dql/functions.rst
Outdated
|
|
||
| ``query("query_expression" [, option=<option_value>]*)`` | ||
|
|
||
| This is an alternative syntax to the `query_string`_ function. The query 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. |
There was a problem hiding this comment.
| This is an alternative syntax to the `query_string`_ function. The query 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 `query` function is an alternative syntax to the `query_string` function. It 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 query expression. |
There was a problem hiding this comment.
Do we want to remove the links entirely? They were originally added to address this comment
There was a problem hiding this comment.
You can apply the change and restore the link.
There was a problem hiding this comment.
I changed the language to match the suggestion, but kept the link to query_string. Please let me know if you are ok with this. Done in 7add05f
| void query_expression() { | ||
| assertAnalyzeEqual( | ||
| dsl.query( | ||
| dsl.namedArgument("query", DSL.literal("query_value"))), |
There was a problem hiding this comment.
nit: change "query_value" to "sample query" or "field:query" or something similar.
Signed-off-by: GabeFernandez310 <gabrielf@bitquilltech.com>
ef2f4c9 to
52ea1e5
Compare
Description
Added query function to SQL plugin. Achieved by routing function calls from the SQL plugin to the query_string function which currently exists in OpenSearch.
Currently blocked by opensearch-project#839. PR to upstream will be made once PR opensearch-project#839 is merged.
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.