-
Notifications
You must be signed in to change notification settings - Fork 138
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
#639: allow metadata fields and score opensearch function (#228) #1456
#639: allow metadata fields and score opensearch function (#228) #1456
Conversation
…nction (#228) * Rebase from main Signed-off-by: Andrew Carbonetto <[email protected]> * Update to define and include metadata when visiting the expr node Signed-off-by: Andrew Carbonetto <[email protected]> * Add specific metadata identifiers Signed-off-by: Andrew Carbonetto <[email protected]> * Add IT tests and add parser changes Signed-off-by: Andrew Carbonetto <[email protected]> * Rebase from main Signed-off-by: Andrew Carbonetto <[email protected]> * Update score function expression analyzer to return boosted relevance function Signed-off-by: Andrew Carbonetto <[email protected]> * Update builder to track scores Signed-off-by: Andrew Carbonetto <[email protected]> * Remove ScoreExpression.java and cleanup checkstyle Signed-off-by: Andrew Carbonetto <[email protected]> * cleanup checkstyle Signed-off-by: Andrew Carbonetto <[email protected]> * Cleanup and add alternative score function syntax Signed-off-by: Andrew Carbonetto <[email protected]> * Cleanup and add alternative score function syntax Signed-off-by: Andrew Carbonetto <[email protected]> * Fix some bugs and add Expression tests Signed-off-by: Andrew Carbonetto <[email protected]> * Add expresssion and analyzer tests Signed-off-by: Andrew Carbonetto <[email protected]> * Add score doctests Signed-off-by: Andrew Carbonetto <[email protected]> * Add score function doctests Signed-off-by: Andrew Carbonetto <[email protected]> * Add metafield tests Signed-off-by: Andrew Carbonetto <[email protected]> * Move legacy test and mark old as ignore Signed-off-by: Andrew Carbonetto <[email protected]> * fix checkstyle violations Signed-off-by: Andrew Carbonetto <[email protected]> * fix checkstyle violations Signed-off-by: Andrew Carbonetto <[email protected]> * Update tests and identifier to accept metafields Signed-off-by: Andrew Carbonetto <[email protected]> * Checkstyle fixes Signed-off-by: Andrew Carbonetto <[email protected]> * Rebase from main Signed-off-by: Andrew Carbonetto <[email protected]> * Rebase from main Signed-off-by: Andrew Carbonetto <[email protected]> * Rebase from main Signed-off-by: Andrew Carbonetto <[email protected]> * fix checkstyle violations Signed-off-by: Andrew Carbonetto <[email protected]> * Revert bad conflict resolution Signed-off-by: Andrew Carbonetto <[email protected]> * Fix for review comments Signed-off-by: Andrew Carbonetto <[email protected]> * Update IT tests and legacy tests for comments Signed-off-by: Andrew Carbonetto <[email protected]> * Minor comment Signed-off-by: Andrew Carbonetto <[email protected]> * Updates for whitespace Signed-off-by: Andrew Carbonetto <[email protected]> * Update basics.rst to show OS result Signed-off-by: Andrew Carbonetto <[email protected]> * Update basics.rst to show OS result Signed-off-by: Andrew Carbonetto <[email protected]> * Update basics.rst description Signed-off-by: Andrew Carbonetto <[email protected]> * Change Score function to accept a double/integer not an unresolved Signed-off-by: Andrew Carbonetto <[email protected]> * Update functions.rst Signed-off-by: Andrew Carbonetto <[email protected]> * Checkstyle update Signed-off-by: Andrew Carbonetto <[email protected]> * Move reserved world symbol table to OpenSearchTable Signed-off-by: Andrew Carbonetto <[email protected]> * Update functions.rst for review comments Signed-off-by: Andrew Carbonetto <[email protected]> * Removed parser meta tokens; Changes ImmutableMap to Map Signed-off-by: Andrew Carbonetto <[email protected]> * Removed parser meta tokens; Changes ImmutableMap to Map Signed-off-by: Andrew Carbonetto <[email protected]> --------- Signed-off-by: Andrew Carbonetto <[email protected]>
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #1456 +/- ##
============================================
+ Coverage 98.46% 98.49% +0.02%
- Complexity 3869 3928 +59
============================================
Files 345 347 +2
Lines 9603 9771 +168
Branches 616 645 +29
============================================
+ Hits 9456 9624 +168
Misses 142 142
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it 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.
@acarbonetto Do metafields work with aliases? E.g. SELECT h._id FROM tableA AS h
Is there a test that confirms this?
Signed-off-by: Andrew Carbonetto <[email protected]>
IT test for this added in f3d89b8 |
core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java
Outdated
Show resolved
Hide resolved
// Identifiers cannot start with a single '_' since this an OpenSearch reserved | ||
// metadata field. Two underscores (or more) is acceptable, such as '__field'. |
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.
Does this comment match the rule below? So ID_LITERAL
won't accept token starting with single underscore?
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.
Good catch! I need to update this comment since I've updated the pattern.
Thank you!
opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/analysis/ExpressionReferenceOptimizer.java
Show resolved
Hide resolved
FetchSourceContext fetchSource = this.sourceBuilder.fetchSource(); | ||
List<String> includes = fetchSource != null && fetchSource.includes() != null | ||
? Arrays.asList(fetchSource.includes()) | ||
: List.of(); |
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.
May be do this in the query builder?
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.
OpenSearchQueryRequest and OpenSearchScrollRequest needs a refactor before this makes any sense.
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.
Please assist in creating an issue to monitor and manage future modifications.
opensearch/src/main/java/org/opensearch/sql/opensearch/request/OpenSearchScrollRequest.java
Show resolved
Hide resolved
opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Andrew Carbonetto <[email protected]>
ccdc290
Signed-off-by: Andrew Carbonetto <[email protected]>
…ction (#228) (#1456) Allow metadata fields and score OpenSearch function. Signed-off-by: Andrew Carbonetto <[email protected]> (cherry picked from commit e805151)
…ction (#228) (#1456) Allow metadata fields and score OpenSearch function. Signed-off-by: Andrew Carbonetto <[email protected]> (cherry picked from commit e805151)
…ion (#228) (#1509) * #639: Support OpenSearch metadata fields and the score OpenSearch function (#228) (#1456) Signed-off-by: Andrew Carbonetto <[email protected]> Co-authored-by: Andrew Carbonetto <[email protected]>
…ion (#228) (#1508) * #639: Support OpenSearch metadata fields and the score OpenSearch function (#228) (#1456) Signed-off-by: Andrew Carbonetto <[email protected]> Co-authored-by: Andrew Carbonetto <[email protected]>
…elds and the score OpenSearch function (#228) (opensearch-project#1456) Allow metadata fields and score OpenSearch function. Signed-off-by: Andrew Carbonetto <[email protected]>
Description
OpenSearch reserved fields (_id, _index, _sort, _score, _max_score) are not allowed to be used in SQL clauses (SELECT, WHERE, ORDER BY) because the field format starting with underscore _ is not allowed.
This ticket allows for the
score()
,score_query()
andscorequery()
function to be used to wrap around relevance-search queries to force the_score
and_max_score
metadata fields to be returned with values. For some queries,_score
returnsnull
unless thescore()
function is included.score
function also allows for an optionalboost
argument to be included that boosts the score of the child relevance function.Example - metadata fields returned:
Example - Metadata fields not requested are not displayed:
Example - relevance search without and with score function
Example - boost score on the _sql/_explain call:
Issues Resolved
__
is missing in the returned result when query by SQL with extrafilter
#783Check 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.