1919import org .elasticsearch .xpack .esql .core .querydsl .query .QueryStringQuery ;
2020import org .elasticsearch .xpack .esql .core .tree .NodeInfo ;
2121import org .elasticsearch .xpack .esql .core .tree .Source ;
22+ import org .elasticsearch .xpack .esql .core .type .DataType ;
2223import org .elasticsearch .xpack .esql .expression .function .Example ;
2324import org .elasticsearch .xpack .esql .expression .function .FunctionInfo ;
2425import org .elasticsearch .xpack .esql .expression .function .Param ;
2728import java .io .IOException ;
2829import java .util .List ;
2930import java .util .Locale ;
31+ import java .util .Set ;
3032
3133import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .ParamOrdinal .FIRST ;
3234import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .ParamOrdinal .SECOND ;
33- import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .isNotNull ;
34- import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .isString ;
35+ import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .isType ;
36+ import static org .elasticsearch .xpack .esql .core .type .DataType .BOOLEAN ;
37+ import static org .elasticsearch .xpack .esql .core .type .DataType .DATETIME ;
38+ import static org .elasticsearch .xpack .esql .core .type .DataType .DATE_NANOS ;
39+ import static org .elasticsearch .xpack .esql .core .type .DataType .DOUBLE ;
40+ import static org .elasticsearch .xpack .esql .core .type .DataType .INTEGER ;
41+ import static org .elasticsearch .xpack .esql .core .type .DataType .IP ;
42+ import static org .elasticsearch .xpack .esql .core .type .DataType .KEYWORD ;
43+ import static org .elasticsearch .xpack .esql .core .type .DataType .LONG ;
44+ import static org .elasticsearch .xpack .esql .core .type .DataType .TEXT ;
45+ import static org .elasticsearch .xpack .esql .core .type .DataType .UNSIGNED_LONG ;
46+ import static org .elasticsearch .xpack .esql .core .type .DataType .VERSION ;
3547
3648/**
3749 * Full text function that performs a {@link QueryStringQuery} .
@@ -44,6 +56,19 @@ public class Match extends FullTextFunction implements Validatable {
4456
4557 private transient Boolean isOperator ;
4658
59+ public static final Set <DataType > DATA_TYPES = Set .of (
60+ KEYWORD ,
61+ TEXT ,
62+ BOOLEAN ,
63+ DATETIME ,
64+ DATE_NANOS ,
65+ DOUBLE ,
66+ INTEGER ,
67+ IP ,
68+ LONG ,
69+ UNSIGNED_LONG ,
70+ VERSION );
71+
4772 @ FunctionInfo (
4873 returnType = "boolean" ,
4974 preview = true ,
@@ -52,10 +77,14 @@ public class Match extends FullTextFunction implements Validatable {
5277 )
5378 public Match (
5479 Source source ,
55- @ Param (name = "field" , type = { "keyword" , "text" }, description = "Field that the query will target." ) Expression field ,
80+ @ Param (
81+ name = "field" ,
82+ type = { "keyword" , "text" , "boolean" , "date" , "date_nanos" , "double" , "integer" , "ip" , "long" , "unsigned_long" , "version" },
83+ description = "Field that the query will target."
84+ ) Expression field ,
5685 @ Param (
5786 name = "query" ,
58- type = { "keyword" , "text" },
87+ type = { "keyword" , "text" , "boolean" , "date" , "date_nanos" , "double" , "integer" , "ip" , "long" , "unsigned_long" , "version" },
5988 description = "Text you wish to find in the provided field."
6089 ) Expression matchQuery
6190 ) {
@@ -84,7 +113,24 @@ public String getWriteableName() {
84113
85114 @ Override
86115 protected TypeResolution resolveNonQueryParamTypes () {
87- return isNotNull (field , sourceText (), FIRST ).and (isString (field , sourceText (), FIRST )).and (super .resolveNonQueryParamTypes ());
116+ return isType (
117+ field ,
118+ DATA_TYPES ::contains ,
119+ functionName (),
120+ FIRST ,
121+ "keyword, text, boolean, date, date_nanos, double, integer, ip, long, unsigned_long, version"
122+ );
123+ }
124+
125+ @ Override
126+ protected TypeResolution resolveQueryParamType () {
127+ return isType (
128+ query (),
129+ DATA_TYPES ::contains ,
130+ functionName (),
131+ queryParamOrdinal (),
132+ "keyword, text, boolean, date, date_nanos, double, integer, ip, long, unsigned_long, version"
133+ );
88134 }
89135
90136 @ Override
0 commit comments