77
88package org .elasticsearch .xpack .esql .expression .function .fulltext ;
99
10+ import org .elasticsearch .TransportVersions ;
1011import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
1112import org .elasticsearch .common .io .stream .StreamInput ;
13+ import org .elasticsearch .common .io .stream .StreamOutput ;
14+ import org .elasticsearch .index .query .QueryBuilder ;
1215import org .elasticsearch .xpack .esql .core .expression .Expression ;
1316import org .elasticsearch .xpack .esql .core .tree .NodeInfo ;
1417import org .elasticsearch .xpack .esql .core .tree .Source ;
2326/**
2427 * This class performs a {@link org.elasticsearch.xpack.esql.querydsl.query.MatchQuery} using an operator.
2528 */
26- public class MatchOperator extends Match {
29+ public class MatchOperator extends AbstractMatchFullTextFunction {
2730
2831 public static final NamedWriteableRegistry .Entry ENTRY = new NamedWriteableRegistry .Entry (
2932 Expression .class ,
@@ -60,15 +63,11 @@ public MatchOperator(
6063 description = "Value to find in the provided field."
6164 ) Expression matchQuery
6265 ) {
63- super (source , field , matchQuery );
66+ this (source , field , matchQuery , null );
6467 }
6568
66- private static Match readFrom (StreamInput in ) throws IOException {
67- Source source = Source .readFrom ((PlanStreamInput ) in );
68- Expression field = in .readNamedWriteable (Expression .class );
69- Expression query = in .readNamedWriteable (Expression .class );
70-
71- return new MatchOperator (source , field , query );
69+ private MatchOperator (Source source , Expression field , Expression matchQuery , QueryBuilder queryBuilder ) {
70+ super (source , matchQuery , List .of (field , matchQuery ), queryBuilder , field );
7271 }
7372
7473 @ Override
@@ -86,6 +85,27 @@ public String getWriteableName() {
8685 return ENTRY .name ;
8786 }
8887
88+ private static MatchOperator readFrom (StreamInput in ) throws IOException {
89+ Source source = Source .readFrom ((PlanStreamInput ) in );
90+ Expression field = in .readNamedWriteable (Expression .class );
91+ Expression query = in .readNamedWriteable (Expression .class );
92+ QueryBuilder queryBuilder = null ;
93+ if (in .getTransportVersion ().onOrAfter (TransportVersions .ESQL_QUERY_BUILDER_IN_SEARCH_FUNCTIONS )) {
94+ queryBuilder = in .readOptionalNamedWriteable (QueryBuilder .class );
95+ }
96+ return new MatchOperator (source , field , query , queryBuilder );
97+ }
98+
99+ @ Override
100+ public void writeTo (StreamOutput out ) throws IOException {
101+ source ().writeTo (out );
102+ out .writeNamedWriteable (field ());
103+ out .writeNamedWriteable (query ());
104+ if (out .getTransportVersion ().onOrAfter (TransportVersions .ESQL_QUERY_BUILDER_IN_SEARCH_FUNCTIONS )) {
105+ out .writeOptionalNamedWriteable (queryBuilder ());
106+ }
107+ }
108+
89109 @ Override
90110 protected NodeInfo <? extends Expression > info () {
91111 return NodeInfo .create (this , MatchOperator ::new , field (), query ());
0 commit comments