Repository navigation
simple_query_string implementation. - #66
Yury-Fridlyand merged 9 commits into
Conversation
#192-impl2`, since that branch was corrupted by incorrect merge. Signed-off-by: Yury Fridlyand <[email protected]>
Codecov Report
@@ Coverage Diff @@
## dev-simple_query_string-#192 #66 +/- ##
==================================================================
+ Coverage 97.66% 97.69% +0.02%
- Complexity 2743 2777 +34
==================================================================
Files 268 269 +1
Lines 6772 6859 +87
Branches 435 437 +2
==================================================================
+ Hits 6614 6701 +87
Misses 157 157
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
…ing-#192-impl3 Signed-off-by: Yury Fridlyand <[email protected]>
| import org.opensearch.sql.expression.NamedArgumentExpression; | ||
| import org.opensearch.sql.opensearch.storage.script.filter.lucene.LuceneQuery; | ||
|
|
||
| public class SimpleQueryStringQuery extends LuceneQuery { |
There was a problem hiding this comment.
There's a base class for common code for relevance queries -- RelevanceQuery.
Let's refactor it so that SimpleQueryStringQuery can use it as well before we send this to upstream.
| // 1) DSL reverses order of the `fields` | ||
| // 2) `flags` are printed by OpenSearch (not by the plugin) as an integer | ||
| // 3) parameters are printed -//- not in lexicographical order | ||
| @Disabled |
There was a problem hiding this comment.
If the test does not work, can we remove it? If not, then let's fix it.
| return new Function( | ||
| ctx.relevanceFunctionName().getText().toLowerCase(), | ||
| relevanceArguments(ctx)); | ||
| if (ctx.singleFieldRelevanceFunction() != null) { |
There was a problem hiding this comment.
There is visitSingleFieldRelevanceFunction in the base class that would be more appropriate place for this code.
| .singleFieldRelevanceFunctionName().getText().toLowerCase(), | ||
| singleFieldRelevanceArguments(ctx.singleFieldRelevanceFunction())); | ||
| } else { | ||
| return new Function( |
There was a problem hiding this comment.
There is visitMultiFieldRelevanceFunction in the base class that would be more appropriate place for this code.
| // - fields' weights inside quotes | ||
| // - `flags` as an integer, but not as an enum | ||
| // - parameters not in alphabetical order | ||
| @Disabled |
There was a problem hiding this comment.
Let's make this test work or remove it.
| @AllArgsConstructor | ||
| public class RelevanceFieldList extends UnresolvedExpression { | ||
| @Getter | ||
| private java.util.Map<UnresolvedExpression, UnresolvedExpression> fieldList; |
There was a problem hiding this comment.
I believe we can make this into a string-float map.
This would improve and simplify the places that use the class as well.
There was a problem hiding this comment.
We talked about using the Field class to store the string/float parameters. If that doesn't work, we should consider creating an Object to store this information.
| .stream() | ||
| .collect(ImmutableMap.toImmutableMap( | ||
| n -> n.getKey().toString(), | ||
| n -> ExprValueUtils.floatValue((Float) ((Literal) n.getValue()).getValue()) |
There was a problem hiding this comment.
Without simplified RelevanceFieldList, this will fail if RelevanceFieldList is anything other than string-float map.
| + Index.BEER.getName() + " WHERE simple_query_string(['Tags'], 'taste')"; | ||
| var result1 = new JSONObject(executeQuery(query1, "jdbc")); | ||
| String query2 = "SELECT count(*) FROM " | ||
| + Index.BEER.getName() + " WHERE simple_query_string(['T*'], 'taste')"; |
There was a problem hiding this comment.
Couldn't TestConstants.TEST_INDEX_BEER be used here?
| // Field is a list of columns | ||
| multiFieldRelevanceFunction | ||
| : multiFieldRelevanceFunctionName LR_BRACKET | ||
| LT_SQR_PRTHS field=relevanceFieldAndWeight (COMMA field=relevanceFieldAndWeight)* RT_SQR_PRTHS |
There was a problem hiding this comment.
I believe if we add a separate rule for field list (everything between square brackets), we can simplify AstExpressionBuilder.
| return new Function( | ||
| ctx.relevanceFunctionName().getText().toLowerCase(), | ||
| relevanceArguments(ctx)); | ||
| if (ctx.singleFieldRelevanceFunction() != null) { |
There was a problem hiding this comment.
Similar comments I made for PPL AstExpressionBuilder apply here.
…ace. Signed-off-by: Yury Fridlyand <[email protected]>
Signed-off-by: Yury Fridlyand <[email protected]>
…y processing. Signed-off-by: Yury Fridlyand <[email protected]>
Signed-off-by: Yury Fridlyand <[email protected]>
Signed-off-by: Yury Fridlyand <[email protected]>
Signed-off-by: Yury Fridlyand <[email protected]>
| // Operators. Bit | ||
|
|
||
| BIT_NOT_OP: '~'; | ||
| //BIT_OR_OP: '|'; |
| REWRITE: 'REWRITE'; | ||
| SLOP: 'SLOP'; | ||
| TIE_BREAKER: 'TIE_BREAKER'; | ||
| //TIME_ZONE: 'TIME_ZONE'; // already defined on line 63 |
Signed-off-by: Yury Fridlyand <[email protected]>
Adding workflow for creating documentation issues
Implementation for
simple_query_stringcopied fromdev-simple_query_string-#192-impl2, since that branch was corrupted by incorrect merge.See also #61.
All PR review notes have been addressed.
Signed-off-by: Yury Fridlyand [email protected]
Description
Issues Resolved
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.