-
Notifications
You must be signed in to change notification settings - Fork 0
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
simple_query_string
implementation.
#66
simple_query_string
implementation.
#66
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 521beca.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the test does not work, can we remove it? If not, then let's fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 2ac159f.
return new Function( | ||
ctx.relevanceFunctionName().getText().toLowerCase(), | ||
relevanceArguments(ctx)); | ||
if (ctx.singleFieldRelevanceFunction() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is visitSingleFieldRelevanceFunction in the base class that would be more appropriate place for this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0817d9e.
.singleFieldRelevanceFunctionName().getText().toLowerCase(), | ||
singleFieldRelevanceArguments(ctx.singleFieldRelevanceFunction())); | ||
} else { | ||
return new Function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is visitMultiFieldRelevanceFunction in the base class that would be more appropriate place for this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0817d9e.
// - 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this test work or remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 2ac159f.
@AllArgsConstructor | ||
public class RelevanceFieldList extends UnresolvedExpression { | ||
@Getter | ||
private java.util.Map<UnresolvedExpression, UnresolvedExpression> fieldList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 015aa06.
.stream() | ||
.collect(ImmutableMap.toImmutableMap( | ||
n -> n.getKey().toString(), | ||
n -> ExprValueUtils.floatValue((Float) ((Literal) n.getValue()).getValue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without simplified RelevanceFieldList, this will fail if RelevanceFieldList is anything other than string-float map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 015aa06.
+ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't TestConstants.TEST_INDEX_BEER
be used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c1a91fc.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comments I made for PPL AstExpressionBuilder apply here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0817d9e.
…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]>
...rc/test/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilderTest.java
Show resolved
Hide resolved
// Operators. Bit | ||
|
||
BIT_NOT_OP: '~'; | ||
//BIT_OR_OP: '|'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b3bca7c.
REWRITE: 'REWRITE'; | ||
SLOP: 'SLOP'; | ||
TIE_BREAKER: 'TIE_BREAKER'; | ||
//TIME_ZONE: 'TIME_ZONE'; // already defined on line 63 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b3bca7c.
Signed-off-by: Yury Fridlyand <[email protected]>
Adding workflow for creating documentation issues
Implementation for
simple_query_string
copied 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.