@@ -1217,13 +1217,22 @@ public void testMatchInsideEval() throws Exception {
12171217
12181218 public void testFieldBasedFullTextFunctions () throws Exception {
12191219 testFieldBasedWithNonIndexedColumn ("MATCH" , "match(text, \" cat\" )" , "function" );
1220- testFieldBasedWithNonIndexedColumn (":" , "text : \" cat\" " , "operator" );
1221- testFieldBasedWithNonIndexedColumn ("MultiMatch" , "multi_match(\" cat\" , text)" , "function" );
1222-
12231220 testFieldBasedFunctionNotAllowedAfterCommands ("MATCH" , "function" , "match(first_name, \" Anna\" )" );
1221+
1222+ testFieldBasedWithNonIndexedColumn (":" , "text : \" cat\" " , "operator" );
12241223 testFieldBasedFunctionNotAllowedAfterCommands (":" , "operator" , "first_name : \" Anna\" " );
1225- testFieldBasedFunctionNotAllowedAfterCommands ("MultiMatch" , "function" , "multi_match(\" Anna\" , first_name)" );
1226- testFieldBasedFunctionNotAllowedAfterCommands ("KNN" , "function" , "knn(vector, [1, 2, 3])" );
1224+
1225+ if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
1226+ testFieldBasedWithNonIndexedColumn ("MultiMatch" , "multi_match(\" cat\" , text)" , "function" );
1227+ testFieldBasedFunctionNotAllowedAfterCommands ("MultiMatch" , "function" , "multi_match(\" Anna\" , first_name)" );
1228+ }
1229+ if (EsqlCapabilities .Cap .TERM_FUNCTION .isEnabled ()) {
1230+ testFieldBasedWithNonIndexedColumn ("Term" , "term(text, \" cat\" )" , "function" );
1231+ testFieldBasedFunctionNotAllowedAfterCommands ("Term" , "function" , "term(first_name, \" Anna\" )" );
1232+ }
1233+ if (EsqlCapabilities .Cap .KNN_FUNCTION .isEnabled ()) {
1234+ testFieldBasedFunctionNotAllowedAfterCommands ("KNN" , "function" , "knn(vector, [1, 2, 3])" );
1235+ }
12271236 }
12281237
12291238 public void testFieldBasedFunctionNotAllowedAfterCommands (String functionName , String functionType , String functionInvocation )
@@ -1380,10 +1389,12 @@ private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, Strin
13801389
13811390 public void testFullTextFunctionsDisjunctions () {
13821391 checkWithFullTextFunctionsDisjunctions ("match(last_name, \" Smith\" )" );
1383- checkWithFullTextFunctionsDisjunctions ("multi_match(\" Smith\" , first_name, last_name)" );
13841392 checkWithFullTextFunctionsDisjunctions ("last_name : \" Smith\" " );
13851393 checkWithFullTextFunctionsDisjunctions ("qstr(\" last_name: Smith\" )" );
13861394 checkWithFullTextFunctionsDisjunctions ("kql(\" last_name: Smith\" )" );
1395+ if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
1396+ checkWithFullTextFunctionsDisjunctions ("multi_match(\" Smith\" , first_name, last_name)" );
1397+ }
13871398 if (EsqlCapabilities .Cap .TERM_FUNCTION .isEnabled ()) {
13881399 checkWithFullTextFunctionsDisjunctions ("term(last_name, \" Smith\" )" );
13891400 }
@@ -1440,12 +1451,12 @@ public void testFullTextFunctionsWithNonBooleanFunctions() {
14401451 if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
14411452 checkFullTextFunctionsWithNonBooleanFunctions ("MultiMatch" , "multi_match(\" Anna\" , first_name, last_name)" , "function" );
14421453 }
1443- if (EsqlCapabilities .Cap .KNN_FUNCTION .isEnabled ()) {
1444- checkFullTextFunctionsWithNonBooleanFunctions ("KNN" , "knn(vector, [1, 2, 3])" , "function" );
1445- }
14461454 if (EsqlCapabilities .Cap .TERM_FUNCTION .isEnabled ()) {
14471455 checkFullTextFunctionsWithNonBooleanFunctions ("Term" , "term(first_name, \" Anna\" )" , "function" );
14481456 }
1457+ if (EsqlCapabilities .Cap .KNN_FUNCTION .isEnabled ()) {
1458+ checkFullTextFunctionsWithNonBooleanFunctions ("KNN" , "knn(vector, [1, 2, 3])" , "function" );
1459+ }
14491460 }
14501461
14511462 private void checkFullTextFunctionsWithNonBooleanFunctions (String functionName , String functionInvocation , String functionType ) {
@@ -2103,12 +2114,15 @@ public void testFullTextFunctionCurrentlyUnsupportedBehaviour() throws Exception
21032114 if (EsqlCapabilities .Cap .TERM_FUNCTION .isEnabled ()) {
21042115 testFullTextFunctionsCurrentlyUnsupportedBehaviour ("term(first_name, \" Anna\" )" );
21052116 }
2117+ if (EsqlCapabilities .Cap .KNN_FUNCTION .isEnabled ()) {
2118+ testFullTextFunctionsCurrentlyUnsupportedBehaviour ("knn(vector, [0, 1, 2])" );
2119+ }
21062120 }
21072121
21082122 private void testFullTextFunctionsCurrentlyUnsupportedBehaviour (String functionInvocation ) throws Exception {
21092123 assertThat (
21102124 error ("from test | stats max_salary = max(salary) by emp_no | where " + functionInvocation ),
2111- containsString ("Unknown column [first_name] " )
2125+ containsString ("Unknown column" )
21122126 );
21132127 }
21142128
@@ -2172,14 +2186,18 @@ public void testInsistNotOnTopOfFrom() {
21722186
21732187 public void testFullTextFunctionsInStats () {
21742188 checkFullTextFunctionsInStats ("match(last_name, \" Smith\" )" );
2175- checkFullTextFunctionsInStats ("multi_match(\" Smith\" , first_name, last_name)" );
21762189 checkFullTextFunctionsInStats ("last_name : \" Smith\" " );
21772190 checkFullTextFunctionsInStats ("qstr(\" last_name: Smith\" )" );
21782191 checkFullTextFunctionsInStats ("kql(\" last_name: Smith\" )" );
2192+ if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
2193+ checkFullTextFunctionsInStats ("multi_match(\" Smith\" , first_name, last_name)" );
2194+ }
2195+ if ( EsqlCapabilities .Cap .KNN_FUNCTION .isEnabled ()) {
2196+ checkFullTextFunctionsInStats ("knn(vector, [0, 1, 2])" );
2197+ }
21792198 }
21802199
21812200 private void checkFullTextFunctionsInStats (String functionInvocation ) {
2182-
21832201 query ("from test | stats c = max(salary) where " + functionInvocation );
21842202 query ("from test | stats c = max(salary) where " + functionInvocation + " or length(first_name) > 10" );
21852203 query ("from test metadata _score | where " + functionInvocation + " | stats c = max(_score)" );
0 commit comments