Skip to content

Commit ba5222f

Browse files
committed
Added test for score without boost
Signed-off-by: Guian Gumpac <[email protected]>
1 parent 5f6eaf2 commit ba5222f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

core/src/test/java/org/opensearch/sql/analysis/OpenSearchAnalyzerTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,33 @@ public void analyze_filter_visit_score_function() {
7272
assertEquals(true, relevanceQuery.isScoreTracked());
7373
}
7474

75+
@Test
76+
public void analyze_filter_visit_score_function_without_boost() {
77+
78+
// setup
79+
OpenSearchFunction scoreFunction = new OpenSearchFunction(
80+
new FunctionName("match_phrase_prefix"), List.of());
81+
when(builtinFunctionRepository.compile(any(), any(), any())).thenReturn(scoreFunction);
82+
83+
UnresolvedPlan unresolvedPlan =
84+
AstDSL.filter(
85+
AstDSL.relation("schema"),
86+
new ScoreFunction(
87+
AstDSL.function(
88+
"match_phrase_prefix",
89+
AstDSL.unresolvedArg("field", stringLiteral("field_value1")),
90+
AstDSL.unresolvedArg("query", stringLiteral("search query"))),
91+
AstDSL.doubleLiteral(1.0)));
92+
93+
// test
94+
LogicalPlan logicalPlan = analyze(unresolvedPlan);
95+
OpenSearchFunction relevanceQuery =
96+
(OpenSearchFunction) ((LogicalFilter) logicalPlan).getCondition();
97+
98+
// verify
99+
assertEquals(true, relevanceQuery.isScoreTracked());
100+
}
101+
75102
@Test
76103
public void analyze_filter_visit_score_function_with_unsupported_boost_SemanticCheckException() {
77104

0 commit comments

Comments
 (0)