Skip to content

Commit 7ee299d

Browse files
committed
Fix class structure and serialization code for 8.x
1 parent 1f4e7b3 commit 7ee299d

File tree

1 file changed

+28
-8
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext

1 file changed

+28
-8
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/MatchOperator.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77

88
package org.elasticsearch.xpack.esql.expression.function.fulltext;
99

10+
import org.elasticsearch.TransportVersions;
1011
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1112
import org.elasticsearch.common.io.stream.StreamInput;
13+
import org.elasticsearch.common.io.stream.StreamOutput;
14+
import org.elasticsearch.index.query.QueryBuilder;
1215
import org.elasticsearch.xpack.esql.core.expression.Expression;
1316
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
1417
import org.elasticsearch.xpack.esql.core.tree.Source;
@@ -23,7 +26,7 @@
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

Comments
 (0)