Skip to content

Commit 890c3a9

Browse files
Apply fix from Carlos
1 parent 876c1ce commit 890c3a9

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.common.util.FeatureFlag;
1313
import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
1414
import org.elasticsearch.xpack.esql.core.expression.Expression;
15+
import org.elasticsearch.xpack.esql.core.expression.MapExpression;
1516
import org.elasticsearch.xpack.esql.core.expression.function.Function;
1617
import org.elasticsearch.xpack.esql.core.tree.Source;
1718
import org.elasticsearch.xpack.esql.core.type.DataType;
@@ -1025,7 +1026,12 @@ protected static <T extends Function> FunctionDefinition def(
10251026
} else if (hasMinimumOne == false && children.size() < 2) {
10261027
throw new QlIllegalArgumentException("expects at least two arguments");
10271028
}
1028-
return ctorRef.build(source, children.get(0), children.subList(1, children.size() - 1), children.getLast());
1029+
Expression options = children.getLast();
1030+
if (options instanceof MapExpression) {
1031+
return ctorRef.build(source, children.get(0), children.subList(1, children.size() - 1), options);
1032+
}
1033+
1034+
return ctorRef.build(source, children.get(0), children.subList(1, children.size()), null);
10291035
};
10301036
return def(function, builder, names);
10311037
}

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,18 @@ public String getWriteableName() {
307307

308308
@Override
309309
public Expression replaceChildren(List<Expression> newChildren) {
310-
return new MultiMatch(
311-
source(),
312-
newChildren.getFirst(),
313-
newChildren.subList(1, newChildren.size() - 1),
314-
newChildren.getLast(),
315-
queryBuilder()
316-
);
310+
if (newChildren.getLast() instanceof MapExpression) {
311+
// if the last child is a MapExpression, it is the options map
312+
return new MultiMatch(
313+
source(),
314+
newChildren.getFirst(),
315+
newChildren.subList(1, newChildren.size() - 1),
316+
newChildren.getLast(),
317+
queryBuilder()
318+
);
319+
}
320+
321+
return new MultiMatch(source(), newChildren.getFirst(), newChildren.subList(1, newChildren.size()), null, queryBuilder());
317322
}
318323

319324
@Override

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,8 @@ public void testQueryStringOptions() {
23252325

23262326
public void testMultiMatchOptions() {
23272327
// Check positive cases
2328+
query("FROM test | WHERE MULTI_MATCH(\"Jean\", first_name)");
2329+
query("FROM test | WHERE MULTI_MATCH(\"Jean\", first_name, {\"analyzer\": \"standard\"})");
23282330
query("FROM test | WHERE MULTI_MATCH(\"Jean\", first_name, last_name, {\"analyzer\": \"standard\"})");
23292331
query("FROM test | WHERE MULTI_MATCH(\"Jean\", \"first_name\", last_name, {\"slop\": 10})");
23302332
query("FROM test | WHERE MULTI_MATCH(\"Jean\", first_name, last_name, {\"auto_generate_synonyms_phrase_query\": true})");

0 commit comments

Comments
 (0)