Skip to content

Take match_phrase out of snapshot and make tech preview #128925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/128925.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 128925
summary: ES|QL - Add `match_phrase` full text function (tech preview)
area: ES|QL
type: enhancement
issues: []

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
* [preview] [`KQL`](../../functions-operators/search-functions.md#esql-kql)
* [preview] [`MATCH`](../../functions-operators/search-functions.md#esql-match)
% * [preview] [
`MATCH_PHRASE`](../../functions-operators/search-functions.md#esql-match-phrase)
* [preview] [`MATCH_PHRASE`](../../functions-operators/search-functions.md#esql-match_phrase)
* [preview] [`QSTR`](../../functions-operators/search-functions.md#esql-qstr)
% * [preview] [
`TERM`](../../functions-operators/search-functions.md#esql-term)
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ for information on the limitations of full text search.
:::{include} ../_snippets/functions/layout/match.md
:::

% MATCH_PHRASE is currently hidden
% :::{include} ../_snippets/functions/layout/match_phrase.md
% :::
:::{include} ../_snippets/functions/layout/match_phrase.md
:::

:::{include} ../_snippets/functions/layout/qstr.md
:::
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.esql.VerificationException;
import org.elasticsearch.xpack.esql.action.AbstractEsqlIntegTestCase;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.elasticsearch.xpack.esql.action.EsqlQueryRequest;
import org.elasticsearch.xpack.esql.action.EsqlQueryResponse;
import org.hamcrest.Matchers;
import org.junit.Before;

Expand All @@ -34,12 +31,6 @@ public void setupIndex() {
createAndPopulateIndex();
}

@Override
protected EsqlQueryResponse run(EsqlQueryRequest request) {
assumeTrue("match_phrase function capability not available", EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled());
return super.run(request);
}

public void testSimpleWhereMatchPhrase() {
var query = """
FROM test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ public static List<Object[]> params() {
params.add(new Object[] { "content:\"fox\"" });
params.add(new Object[] { "qstr(\"content: fox\")" });
params.add(new Object[] { "kql(\"content*: fox\")" });
params.add(new Object[] { "match_phrase(content, \"fox\")" });
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
params.add(new Object[] { "term(content, \"fox\")" });
}
if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
params.add(new Object[] { "match_phrase(content, \"fox\")" });
}
return params;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ public enum Cap {
/**
* MATCH PHRASE function
*/
MATCH_PHRASE_FUNCTION(Build.current().isSnapshot());
MATCH_PHRASE_FUNCTION;

private final boolean enabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
entries.add(Match.ENTRY);
entries.add(MultiMatch.ENTRY);
entries.add(Kql.ENTRY);
entries.add(MatchPhrase.ENTRY);

if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
entries.add(Term.ENTRY);
}

if (EsqlCapabilities.Cap.MATCH_PHRASE_FUNCTION.isEnabled()) {
entries.add(MatchPhrase.ENTRY);
}

return Collections.unmodifiableList(entries);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public class MatchPhrase extends FullTextFunction implements OptionalArgument, P
returnType = "boolean",
preview = true,
description = """
Use `MATCH_PHRASE` to perform a <<query-dsl-match-query-phrase,match_phrase query>> on the specified field.
Use `MATCH_PHRASE` to perform a [`match_phrase`](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) on the
specified field.
Using `MATCH_PHRASE` is equivalent to using the `match_phrase` query in the Elasticsearch Query DSL.

MatchPhrase can be used on <<text, text>> fields, as well as other field types like keyword, boolean, or date types.
Expand Down Expand Up @@ -149,7 +150,7 @@ public MatchPhrase(
description = "Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0."
) },
description = "(Optional) MatchPhrase additional options as <<esql-function-named-params,function named parameters>>."
+ " See <<query-dsl-match-query-phrase,match_phrase query>> for more information.",
+ " See [`match_phrase`](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) for more information.",
optional = true
) Expression options
) {
Expand Down
Loading
Loading