File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,7 @@ protected TypeResolution checkParamCompatibility() {
160160 DataType fieldType = field ().dataType ();
161161 DataType queryType = query ().dataType ();
162162
163+ // Field and query types should match. If the query is a string, then it can match any field type.
163164 if ((fieldType == queryType ) || (queryType == KEYWORD )) {
164165 return TypeResolution .TYPE_RESOLVED ;
165166 }
@@ -193,13 +194,17 @@ public void validate(Failures failures) {
193194 public Object queryAsObject () {
194195 Object queryAsObject = query ().fold ();
195196
197+ // Convert BytesRef to string for string-based values
196198 if (queryAsObject instanceof BytesRef bytesRef ) {
197199 return switch (query ().dataType ()) {
198200 case IP -> EsqlDataTypeConverter .ipToString (bytesRef );
199201 case VERSION -> EsqlDataTypeConverter .versionToString (bytesRef );
200202 default -> bytesRef .utf8ToString ();
201203 };
202- } else if (query ().dataType () == DataType .UNSIGNED_LONG ) {
204+ }
205+
206+ // Converts specific types to the correct type for the query
207+ if (query ().dataType () == DataType .UNSIGNED_LONG ) {
203208 return NumericUtils .unsignedLongAsBigInteger ((Long ) queryAsObject );
204209 } else if (query ().dataType () == DataType .DATETIME && queryAsObject instanceof Long ) {
205210 // When casting to date and datetime, we get a long back. But Match query needs a date string
You can’t perform that action at this time.
0 commit comments