forked from opensearch-project/sql
-
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
#639: allow metadata fields and score opensearch function #228
Merged
Merged
Changes from 32 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
d8b412d
Rebase from main
acarbonetto 5eaa344
Update to define and include metadata when visiting the expr node
acarbonetto ea25455
Add specific metadata identifiers
acarbonetto 9f1dcca
Add IT tests and add parser changes
acarbonetto 5a70363
Rebase from main
acarbonetto 8c0aaf6
Update score function expression analyzer to return boosted relevance…
acarbonetto 4d8229d
Update builder to track scores
acarbonetto 4630c98
Remove ScoreExpression.java and cleanup checkstyle
acarbonetto 9a10273
cleanup checkstyle
acarbonetto 0a92969
Cleanup and add alternative score function syntax
acarbonetto 3b5e900
Cleanup and add alternative score function syntax
acarbonetto 348b8b9
Fix some bugs and add Expression tests
acarbonetto f67d4f2
Add expresssion and analyzer tests
acarbonetto be7191a
Add score doctests
acarbonetto 1a0b3ef
Add score function doctests
acarbonetto 05d9dd3
Add metafield tests
acarbonetto 996a166
Move legacy test and mark old as ignore
acarbonetto 2c469c7
fix checkstyle violations
acarbonetto 4c7a5d7
fix checkstyle violations
acarbonetto dec36fa
Update tests and identifier to accept metafields
acarbonetto 7aab6ee
Checkstyle fixes
acarbonetto fcb3470
Rebase from main
acarbonetto 6e52d13
Rebase from main
acarbonetto 0d3beab
Rebase from main
acarbonetto 1c05aba
fix checkstyle violations
acarbonetto f97dfea
Revert bad conflict resolution
acarbonetto 3ba3c85
Fix for review comments
acarbonetto dd15853
Update IT tests and legacy tests for comments
acarbonetto 543d232
Minor comment
acarbonetto 9d59e9f
Updates for whitespace
acarbonetto 7a05276
Update basics.rst to show OS result
acarbonetto e75d6b5
Update basics.rst to show OS result
acarbonetto fecf615
Update basics.rst description
acarbonetto 47636c3
Change Score function to accept a double/integer not an unresolved
acarbonetto 6d9853c
Update functions.rst
acarbonetto f93f7c4
Checkstyle update
acarbonetto 1340f11
Move reserved world symbol table to OpenSearchTable
acarbonetto bdc3020
Update functions.rst for review comments
acarbonetto 31f0617
Removed parser meta tokens; Changes ImmutableMap to Map
acarbonetto 55b93ac
Removed parser meta tokens; Changes ImmutableMap to Map
acarbonetto 0410521
Merge branch 'integ-metadata-fields' into dev-metadata-fields
acarbonetto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
core/src/main/java/org/opensearch/sql/ast/expression/ScoreFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.ast.expression; | ||
|
||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.opensearch.sql.ast.AbstractNodeVisitor; | ||
|
||
/** | ||
* Expression node of Score function. | ||
* Score takes a relevance-search expression as an argument and returns it | ||
*/ | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
@Getter | ||
@ToString | ||
public class ScoreFunction extends UnresolvedExpression { | ||
private final UnresolvedExpression relevanceQuery; | ||
private final UnresolvedExpression funcArg; | ||
|
||
@Override | ||
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) { | ||
return nodeVisitor.visitScoreFunction(this, context); | ||
} | ||
|
||
@Override | ||
public List<UnresolvedExpression> getChild() { | ||
return List.of(relevanceQuery, funcArg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we need to add this to
opensearch
module as storage-specific function. Personally I think we should prioritize opensearch-project#811. It will become more and more difficult as we keep adding more OpenSearch logic tocore
engine.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.
Agreed. I've got it on our radar, and we can start to scope it out. As is, there's quite a bit of work to do to pull out the opensearch specific classes, but I think it's do-able.
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've had storage-specific function support in opensearch-project#1354. Can we start this now instead of adding more and more special logic to
core
? Agreed there is quite lots of work to move all toopensearch
but maybe easy to do this for single PR?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 me take a look. There's already a lot in this PR.
Would you mind if we move the score function out as a proof of concept for a set of OpenSearch storage engine functions?