Skip to content

Commit e680538

Browse files
committed
Add additional verifier tests
1 parent 1051aed commit e680538

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.xpack.esql.core.type.InvalidMappedField;
2020
import org.elasticsearch.xpack.esql.core.type.UnsupportedEsField;
2121
import org.elasticsearch.xpack.esql.expression.function.fulltext.Match;
22+
import org.elasticsearch.xpack.esql.expression.function.fulltext.MatchPhrase;
2223
import org.elasticsearch.xpack.esql.expression.function.fulltext.MultiMatch;
2324
import org.elasticsearch.xpack.esql.expression.function.fulltext.QueryString;
2425
import org.elasticsearch.xpack.esql.index.EsIndex;
@@ -1363,6 +1364,9 @@ public void testFullTextFunctionsOnlyAllowedInWhere() throws Exception {
13631364
if (EsqlCapabilities.Cap.MULTI_MATCH_FUNCTION.isEnabled()) {
13641365
checkFullTextFunctionsOnlyAllowedInWhere("MultiMatch", "multi_match(\"Meditation\", title, body)", "function");
13651366
}
1367+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
1368+
checkFullTextFunctionsOnlyAllowedInWhere("MatchPhrase", "match_phrase(title, \"Meditation\")", "function");
1369+
}
13661370
}
13671371

13681372
private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, String functionInvocation, String functionType)
@@ -1398,6 +1402,9 @@ public void testFullTextFunctionsDisjunctions() {
13981402
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
13991403
checkWithFullTextFunctionsDisjunctions("term(title, \"Meditation\")");
14001404
}
1405+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
1406+
checkWithFullTextFunctionsDisjunctions("match_phrase(title, \"Meditation\")");
1407+
}
14011408
}
14021409

14031410
private void checkWithFullTextFunctionsDisjunctions(String functionInvocation) {
@@ -1459,6 +1466,9 @@ public void testFullTextFunctionsWithNonBooleanFunctions() {
14591466
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
14601467
checkFullTextFunctionsWithNonBooleanFunctions("Term", "term(title, \"Meditation\")", "function");
14611468
}
1469+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
1470+
checkFullTextFunctionsWithNonBooleanFunctions("MatchPhrase", "match_phrase(title, \"Meditation\")", "function");
1471+
}
14621472
}
14631473

14641474
private void checkFullTextFunctionsWithNonBooleanFunctions(String functionName, String functionInvocation, String functionType) {
@@ -1526,6 +1536,9 @@ public void testFullTextFunctionsTargetsExistingField() throws Exception {
15261536
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
15271537
testFullTextFunctionTargetsExistingField("term(fist_name, \"Meditation\")");
15281538
}
1539+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
1540+
testFullTextFunctionTargetsExistingField("match_phrase(title, \"Meditation\")");
1541+
}
15291542
}
15301543

15311544
private void testFullTextFunctionTargetsExistingField(String functionInvocation) throws Exception {
@@ -2050,6 +2063,9 @@ public void testFullTextFunctionOptions() {
20502063
if (EsqlCapabilities.Cap.MULTI_MATCH_FUNCTION.isEnabled()) {
20512064
checkOptionDataTypes(MultiMatch.OPTIONS, "FROM test | WHERE MULTI_MATCH(\"Jean\", title, body, {\"%s\": %s})");
20522065
}
2066+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
2067+
checkOptionDataTypes(MatchPhrase.ALLOWED_OPTIONS, "FROM test | WHERE MATCH_PHRASE(title, \"Jean\", {\"%s\": %s})");
2068+
}
20532069
}
20542070

20552071
/**
@@ -2110,6 +2126,9 @@ public void testFullTextFunctionCurrentlyUnsupportedBehaviour() throws Exception
21102126
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
21112127
testFullTextFunctionsCurrentlyUnsupportedBehaviour("term(title, \"Meditation\")");
21122128
}
2129+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
2130+
testFullTextFunctionsCurrentlyUnsupportedBehaviour("match_phrase(title, \"Meditation\")");
2131+
}
21132132
}
21142133

21152134
private void testFullTextFunctionsCurrentlyUnsupportedBehaviour(String functionInvocation) throws Exception {
@@ -2132,6 +2151,10 @@ public void testFullTextFunctionsNullArgs() throws Exception {
21322151
checkFullTextFunctionNullArgs("term(null, \"query\")", "first");
21332152
checkFullTextFunctionNullArgs("term(title, null)", "second");
21342153
}
2154+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
2155+
checkFullTextFunctionNullArgs("match_phrase(null, \"query\")", "first");
2156+
checkFullTextFunctionNullArgs("match_phrase(title, null)", "second");
2157+
}
21352158
}
21362159

21372160
private void checkFullTextFunctionNullArgs(String functionInvocation, String argOrdinal) throws Exception {
@@ -2152,6 +2175,9 @@ public void testFullTextFunctionsConstantQuery() throws Exception {
21522175
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
21532176
checkFullTextFunctionsConstantQuery("term(title, tags)", "second");
21542177
}
2178+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
2179+
checkFullTextFunctionsConstantQuery("match_phrase(title, tags)", "second");
2180+
}
21552181
}
21562182

21572183
private void checkFullTextFunctionsConstantQuery(String functionInvocation, String argOrdinal) throws Exception {
@@ -2178,6 +2204,9 @@ public void testFullTextFunctionsInStats() {
21782204
if (EsqlCapabilities.Cap.MULTI_MATCH_FUNCTION.isEnabled()) {
21792205
checkFullTextFunctionsInStats("multi_match(\"Meditation\", title, body)");
21802206
}
2207+
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
2208+
checkFullTextFunctionsInStats("match_phrase(title, \"Meditation\")");
2209+
}
21812210
}
21822211

21832212
private void checkFullTextFunctionsInStats(String functionInvocation) {

0 commit comments

Comments
 (0)