forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opensearch-project#639: allow metadata fields and score opensearch fu…
…nction (#228) * Rebase from main Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update to define and include metadata when visiting the expr node Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Add specific metadata identifiers Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Add IT tests and add parser changes Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Rebase from main Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update score function expression analyzer to return boosted relevance function Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update builder to track scores Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Remove ScoreExpression.java and cleanup checkstyle Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * cleanup checkstyle Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Cleanup and add alternative score function syntax Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Cleanup and add alternative score function syntax Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Fix some bugs and add Expression tests Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Add expresssion and analyzer tests Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Add score doctests Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Add score function doctests Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Add metafield tests Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Move legacy test and mark old as ignore Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * fix checkstyle violations Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * fix checkstyle violations Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update tests and identifier to accept metafields Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Checkstyle fixes Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Rebase from main Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Rebase from main Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Rebase from main Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * fix checkstyle violations Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Revert bad conflict resolution Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Fix for review comments Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update IT tests and legacy tests for comments Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Minor comment Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Updates for whitespace Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update basics.rst to show OS result Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update basics.rst to show OS result Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update basics.rst description Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Change Score function to accept a double/integer not an unresolved Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update functions.rst Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Checkstyle update Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Move reserved world symbol table to OpenSearchTable Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Update functions.rst for review comments Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Removed parser meta tokens; Changes ImmutableMap to Map Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> * Removed parser meta tokens; Changes ImmutableMap to Map Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com> --------- Signed-off-by: Andrew Carbonetto <andrewc@bitquilltech.com>
- Loading branch information
1 parent
d44cd39
commit 3e4e9d7
Showing
38 changed files
with
1,212 additions
and
46 deletions.
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
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 Literal relevanceFieldWeight; | ||
|
||
@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); | ||
} | ||
} |
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.