Skip to content

Commit b214fbf

Browse files
kderussocarlosdelestelasticsearchmachineafoucret
authored
Take match_phrase out of snapshot and make tech preview (#128925)
* Take match_phrase out of snapshot and make tech preview * Update docs/changelog/128925.yaml * PR feedback * Adding regenerated test data * Update docs/changelog/128925.yaml Co-authored-by: Carlos Delgado <[email protected]> * [CI] Auto commit changes from spotless * Checkstyle * Correct docs * Hopefully fix docs build * Found one more bad docs link - here's hoping this now fixes the doc build * OMG bitten by - vs _ --------- Co-authored-by: Carlos Delgado <[email protected]> Co-authored-by: elasticsearchmachine <[email protected]> Co-authored-by: Aurélien FOUCRET <[email protected]>
1 parent 1b49eab commit b214fbf

File tree

15 files changed

+35
-70
lines changed

15 files changed

+35
-70
lines changed

docs/changelog/128925.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128925
2+
summary: ES|QL - Add `match_phrase` full text function (tech preview)
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/reference/query-languages/esql/_snippets/functions/description/match_phrase.md

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

docs/reference/query-languages/esql/_snippets/functions/parameters/match_phrase.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
* [preview] [`KQL`](../../functions-operators/search-functions.md#esql-kql)
22
* [preview] [`MATCH`](../../functions-operators/search-functions.md#esql-match)
3-
% * [preview] [
4-
`MATCH_PHRASE`](../../functions-operators/search-functions.md#esql-match-phrase)
3+
* [preview] [`MATCH_PHRASE`](../../functions-operators/search-functions.md#esql-match_phrase)
54
* [preview] [`QSTR`](../../functions-operators/search-functions.md#esql-qstr)
65
% * [preview] [
76
`TERM`](../../functions-operators/search-functions.md#esql-term)

docs/reference/query-languages/esql/functions-operators/search-functions.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ for information on the limitations of full text search.
3636
:::{include} ../_snippets/functions/layout/match.md
3737
:::
3838

39-
% MATCH_PHRASE is currently hidden
40-
% :::{include} ../_snippets/functions/layout/match_phrase.md
41-
% :::
39+
:::{include} ../_snippets/functions/layout/match_phrase.md
40+
:::
4241

4342
:::{include} ../_snippets/functions/layout/qstr.md
4443
:::

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

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/functions/match_phrase.md

Lines changed: 2 additions & 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/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/MatchPhraseFunctionIT.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
import org.elasticsearch.common.settings.Settings;
1414
import org.elasticsearch.xpack.esql.VerificationException;
1515
import org.elasticsearch.xpack.esql.action.AbstractEsqlIntegTestCase;
16-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
17-
import org.elasticsearch.xpack.esql.action.EsqlQueryRequest;
18-
import org.elasticsearch.xpack.esql.action.EsqlQueryResponse;
1916
import org.hamcrest.Matchers;
2017
import org.junit.Before;
2118

@@ -34,12 +31,6 @@ public void setupIndex() {
3431
createAndPopulateIndex();
3532
}
3633

37-
@Override
38-
protected EsqlQueryResponse run(EsqlQueryRequest request) {
39-
assumeTrue("match_phrase function capability not available", EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled());
40-
return super.run(request);
41-
}
42-
4334
public void testSimpleWhereMatchPhrase() {
4435
var query = """
4536
FROM test

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/ScoringIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ public static List<Object[]> params() {
5050
params.add(new Object[] { "content:\"fox\"" });
5151
params.add(new Object[] { "qstr(\"content: fox\")" });
5252
params.add(new Object[] { "kql(\"content*: fox\")" });
53+
params.add(new Object[] { "match_phrase(content, \"fox\")" });
5354
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
5455
params.add(new Object[] { "term(content, \"fox\")" });
5556
}
56-
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
57-
params.add(new Object[] { "match_phrase(content, \"fox\")" });
58-
}
5957
return params;
6058
}
6159

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ public enum Cap {
11851185
/**
11861186
* MATCH PHRASE function
11871187
*/
1188-
MATCH_PHRASE_FUNCTION(Build.current().isSnapshot());
1188+
MATCH_PHRASE_FUNCTION;
11891189

11901190
private final boolean enabled;
11911191

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
2323
entries.add(Match.ENTRY);
2424
entries.add(MultiMatch.ENTRY);
2525
entries.add(Kql.ENTRY);
26+
entries.add(MatchPhrase.ENTRY);
2627

2728
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
2829
entries.add(Term.ENTRY);
2930
}
3031

31-
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
32-
entries.add(MatchPhrase.ENTRY);
33-
}
34-
3532
return Collections.unmodifiableList(entries);
3633
}
3734
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public class MatchPhrase extends FullTextFunction implements OptionalArgument, P
9494
returnType = "boolean",
9595
preview = true,
9696
description = """
97-
Use `MATCH_PHRASE` to perform a <<query-dsl-match-query-phrase,match_phrase query>> on the specified field.
97+
Use `MATCH_PHRASE` to perform a [`match_phrase`](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) on the
98+
specified field.
9899
Using `MATCH_PHRASE` is equivalent to using the `match_phrase` query in the Elasticsearch Query DSL.
99100
100101
MatchPhrase can be used on <<text, text>> fields, as well as other field types like keyword, boolean, or date types.
@@ -149,7 +150,7 @@ public MatchPhrase(
149150
description = "Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0."
150151
) },
151152
description = "(Optional) MatchPhrase additional options as <<esql-function-named-params,function named parameters>>."
152-
+ " See <<query-dsl-match-query-phrase,match_phrase query>> for more information.",
153+
+ " See [`match_phrase`](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) for more information.",
153154
optional = true
154155
) Expression options
155156
) {

0 commit comments

Comments
 (0)