Skip to content

Commit 77c9fbf

Browse files
committed
PR feedback
1 parent 1cc6eba commit 77c9fbf

File tree

3 files changed

+4
-30
lines changed
  • docs/reference/query-languages/esql/kibana/definition/functions
  • x-pack/plugin/esql/src

3 files changed

+4
-30
lines changed

docs/reference/query-languages/esql/kibana/definition/functions/match_phrase.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ public class MatchPhrase extends FullTextFunction implements OptionalArgument, P
118118
public MatchPhrase(
119119
Source source,
120120
@Param(name = "field", type = { "keyword", "text" }, description = "Field that the query will target.") Expression field,
121-
@Param(
122-
name = "query",
123-
type = { "keyword", "text" },
124-
description = "Value to find in the provided field."
125-
) Expression matchPhraseQuery,
121+
@Param(name = "query", type = { "keyword" }, description = "Value to find in the provided field.") Expression matchPhraseQuery,
126122
@MapParam(
127123
name = "options",
128124
params = {
@@ -200,31 +196,19 @@ public final void writeTo(StreamOutput out) throws IOException {
200196

201197
@Override
202198
protected TypeResolution resolveParams() {
203-
return resolveField().and(resolveQuery()).and(resolveOptions(options(), THIRD)).and(checkParamCompatibility());
199+
return resolveField().and(resolveQuery()).and(resolveOptions(options(), THIRD));
204200
}
205201

206202
private TypeResolution resolveField() {
207203
return isNotNull(field, sourceText(), FIRST).and(isType(field, FIELD_DATA_TYPES::contains, sourceText(), FIRST, "keyword, text"));
208204
}
209205

210206
private TypeResolution resolveQuery() {
211-
return isType(query(), QUERY_DATA_TYPES::contains, sourceText(), SECOND, "keyword, text").and(
207+
return isType(query(), QUERY_DATA_TYPES::contains, sourceText(), SECOND, "keyword").and(
212208
isNotNullAndFoldable(query(), sourceText(), SECOND)
213209
);
214210
}
215211

216-
private TypeResolution checkParamCompatibility() {
217-
DataType fieldType = field().dataType();
218-
DataType queryType = query().dataType();
219-
220-
// Field and query types should match. If the query is a string, then it can match any field type.
221-
if ((fieldType == queryType) || (queryType == KEYWORD) || (queryType == TEXT)) {
222-
return TypeResolution.TYPE_RESOLVED;
223-
}
224-
225-
return new TypeResolution(formatIncompatibleTypesMessage(fieldType, queryType, sourceText()));
226-
}
227-
228212
@Override
229213
protected Map<String, Object> resolvedOptions() throws InvalidArgumentException {
230214
return matchPhraseQueryOptions();

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext/MatchPhraseTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ public static void addStringTestCases(List<TestCaseSupplier> suppliers) {
6969
(o1, o2) -> true
7070
)
7171
);
72-
73-
suppliers.add(
74-
TestCaseSupplier.testCaseSupplier(
75-
queryDataSupplier,
76-
new TestCaseSupplier.TypedDataSupplier(fieldType.typeName(), () -> randomAlphaOfLength(10), DataType.TEXT),
77-
(d1, d2) -> equalTo("string"),
78-
DataType.BOOLEAN,
79-
(o1, o2) -> true
80-
)
81-
);
8272
}
8373
}
8474
}

0 commit comments

Comments
 (0)