@@ -1216,12 +1216,19 @@ public void testMatchInsideEval() throws Exception {
12161216
12171217 public void testFieldBasedFullTextFunctions () throws Exception {
12181218 testFieldBasedWithNonIndexedColumn ("MATCH" , "match(text, \" cat\" )" , "function" );
1219- testFieldBasedWithNonIndexedColumn (":" , "text : \" cat\" " , "operator" );
1220- testFieldBasedWithNonIndexedColumn ("MultiMatch" , "multi_match(\" cat\" , text)" , "function" );
1221-
12221219 testFieldBasedFunctionNotAllowedAfterCommands ("MATCH" , "function" , "match(first_name, \" Anna\" )" );
1220+
1221+ testFieldBasedWithNonIndexedColumn (":" , "text : \" cat\" " , "operator" );
12231222 testFieldBasedFunctionNotAllowedAfterCommands (":" , "operator" , "first_name : \" Anna\" " );
1224- testFieldBasedFunctionNotAllowedAfterCommands ("MultiMatch" , "function" , "multi_match(\" Anna\" , first_name)" );
1223+
1224+ if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
1225+ testFieldBasedWithNonIndexedColumn ("MultiMatch" , "multi_match(\" cat\" , text)" , "function" );
1226+ testFieldBasedFunctionNotAllowedAfterCommands ("MultiMatch" , "function" , "multi_match(\" Anna\" , first_name)" );
1227+ }
1228+ if (EsqlCapabilities .Cap .TERM_FUNCTION .isEnabled ()) {
1229+ testFieldBasedWithNonIndexedColumn ("Term" , "term(text, \" cat\" )" , "function" );
1230+ testFieldBasedFunctionNotAllowedAfterCommands ("Term" , "function" , "term(first_name, \" Anna\" )" );
1231+ }
12251232 }
12261233
12271234 public void testFieldBasedFunctionNotAllowedAfterCommands (String functionName , String functionType , String functionInvocation )
@@ -1375,10 +1382,12 @@ private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, Strin
13751382
13761383 public void testFullTextFunctionsDisjunctions () {
13771384 checkWithFullTextFunctionsDisjunctions ("match(last_name, \" Smith\" )" );
1378- checkWithFullTextFunctionsDisjunctions ("multi_match(\" Smith\" , first_name, last_name)" );
13791385 checkWithFullTextFunctionsDisjunctions ("last_name : \" Smith\" " );
13801386 checkWithFullTextFunctionsDisjunctions ("qstr(\" last_name: Smith\" )" );
13811387 checkWithFullTextFunctionsDisjunctions ("kql(\" last_name: Smith\" )" );
1388+ if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
1389+ checkWithFullTextFunctionsDisjunctions ("multi_match(\" Smith\" , first_name, last_name)" );
1390+ }
13821391 if (EsqlCapabilities .Cap .TERM_FUNCTION .isEnabled ()) {
13831392 checkWithFullTextFunctionsDisjunctions ("term(last_name, \" Smith\" )" );
13841393 }
@@ -2076,17 +2085,6 @@ private static String exampleValueForType(DataType currentType) {
20762085 };
20772086 }
20782087
2079- public void testMultiMatchFunctionArgNotConstant () throws Exception {
2080- assertEquals (
2081- "1:19: second argument of [match(first_name, first_name)] must be a constant, received [first_name]" ,
2082- error ("from test | where match(first_name, first_name)" )
2083- );
2084- assertEquals (
2085- "1:59: second argument of [match(first_name, query)] must be a constant, received [query]" ,
2086- error ("from test | eval query = concat(\" first\" , \" name\" ) | where match(first_name, query)" )
2087- );
2088- }
2089-
20902088 // Should pass eventually once we lift some restrictions on full text search functions.
20912089 public void testFullTextFunctionCurrentlyUnsupportedBehaviour () throws Exception {
20922090 testFullTextFunctionsCurrentlyUnsupportedBehaviour ("match(first_name, \" Anna\" )" );
@@ -2102,7 +2100,7 @@ public void testFullTextFunctionCurrentlyUnsupportedBehaviour() throws Exception
21022100 private void testFullTextFunctionsCurrentlyUnsupportedBehaviour (String functionInvocation ) throws Exception {
21032101 assertThat (
21042102 error ("from test | stats max_salary = max(salary) by emp_no | where " + functionInvocation ),
2105- containsString ("Unknown column [first_name] " )
2103+ containsString ("Unknown column" )
21062104 );
21072105 }
21082106
@@ -2134,6 +2132,7 @@ public void testFullTextFunctionsConstantQuery() throws Exception {
21342132 testFullTextFunctionsConstantQuery ("kql(first_name)" , "" );
21352133 if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
21362134 testFullTextFunctionsConstantQuery ("multi_match(first_name, first_name)" , "first" );
2135+ testFullTextFunctionsConstantQuery ("multi_match(concat(first_name, \" world\" ), first_name)" , "first" );
21372136 }
21382137 if (EsqlCapabilities .Cap .TERM_FUNCTION .isEnabled ()) {
21392138 testFullTextFunctionsConstantQuery ("term(first_name, last_name)" , "second" );
@@ -2158,14 +2157,15 @@ public void testInsistNotOnTopOfFrom() {
21582157
21592158 public void testFullTextFunctionsInStats () {
21602159 checkFullTextFunctionsInStats ("match(last_name, \" Smith\" )" );
2161- checkFullTextFunctionsInStats ("multi_match(\" Smith\" , first_name, last_name)" );
21622160 checkFullTextFunctionsInStats ("last_name : \" Smith\" " );
21632161 checkFullTextFunctionsInStats ("qstr(\" last_name: Smith\" )" );
21642162 checkFullTextFunctionsInStats ("kql(\" last_name: Smith\" )" );
2163+ if (EsqlCapabilities .Cap .MULTI_MATCH_FUNCTION .isEnabled ()) {
2164+ checkFullTextFunctionsInStats ("multi_match(\" Smith\" , first_name, last_name)" );
2165+ }
21652166 }
21662167
21672168 private void checkFullTextFunctionsInStats (String functionInvocation ) {
2168-
21692169 query ("from test | stats c = max(salary) where " + functionInvocation );
21702170 query ("from test | stats c = max(salary) where " + functionInvocation + " or length(first_name) > 10" );
21712171 query ("from test metadata _score | where " + functionInvocation + " | stats c = max(_score)" );
0 commit comments