Skip to content

[ES|QL] Add MATCH_PHRASE #127661

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 54 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3bcc654
Initial commit of match_phrase
kderusso May 2, 2025
baee81b
Add MatchPhraseQueryTests
kderusso May 2, 2025
13ccda7
First pass at CSV specs
kderusso May 6, 2025
c8e6770
Update docs/changelog/127661.yaml
kderusso May 7, 2025
d02864e
Refactor so MatchPhrase doesn't use all fulltext test cases, just tex…
kderusso May 8, 2025
49ae77f
Fix tests
kderusso May 8, 2025
9769fca
Merge main
kderusso May 8, 2025
5f14d2e
Add some CSV test cases
kderusso May 9, 2025
8095a28
Fix test
kderusso May 9, 2025
6ff795b
Merge branch 'main' into kderusso/esql-match-phrase
kderusso May 9, 2025
4220843
Update changelog
kderusso May 9, 2025
4b5f4fa
Update tests
kderusso May 9, 2025
641f65b
Comment out MATCH_PHRASE in search-functions Markdown
kderusso May 14, 2025
b0efb7b
Merge branch 'main' into kderusso/esql-match-phrase
kderusso May 14, 2025
c58c4a8
Minor PR feedback
kderusso May 20, 2025
7f8d663
PR feedback - refactor/consolidate code
kderusso May 20, 2025
e0ae889
Add some more tests
kderusso May 20, 2025
9ebdda2
Fix some tests
kderusso May 20, 2025
45d6810
[CI] Auto commit changes from spotless
elasticsearchmachine May 20, 2025
9b9c150
Update from main
kderusso May 21, 2025
f71620c
Fix tests
kderusso May 21, 2025
4e7a699
PR feedback - add tests, support boost and numeric data
kderusso May 22, 2025
81b2eba
Revert "PR feedback - add tests, support boost and numeric data"
kderusso May 28, 2025
00b21ac
Apply testing/PR feedback outside numeric support only
kderusso May 28, 2025
2151b87
Regenerate docs
kderusso May 28, 2025
286ce04
Add negative test
kderusso May 28, 2025
95e658f
Merge from main
kderusso May 28, 2025
ee5fdc5
Update x-pack/plugin/esql/qa/testFixtures/src/main/resources/match-ph…
kderusso May 28, 2025
2eb24b4
Update x-pack/plugin/esql/qa/testFixtures/src/main/resources/match-ph…
kderusso May 28, 2025
b68c3a0
Update x-pack/plugin/esql/qa/testFixtures/src/main/resources/match-ph…
kderusso May 28, 2025
ace470d
PR feedback
kderusso May 28, 2025
a0fbe08
Merge branch 'kderusso/esql-match-phrase' of github.com:kderusso/elas…
kderusso May 28, 2025
344c8c2
Fix auto-commit error
kderusso May 28, 2025
42579ec
Regenerate docs
kderusso May 28, 2025
e3e42d6
Update x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/…
kderusso May 29, 2025
a3fc9b6
Remove non text field types
kderusso May 29, 2025
aa018d4
Fake test data
kderusso May 29, 2025
f99557d
Merge branch 'main' into kderusso/esql-match-phrase
kderusso May 29, 2025
1b16c8d
Remove tests that no longer should pass without ip/date/version support
kderusso May 30, 2025
4d82eb5
Merge branch 'main' into kderusso/esql-match-phrase
kderusso May 30, 2025
50fe44f
Put real data in score tests now that I was able to engineer a failure
kderusso May 30, 2025
d44973b
Merge branch 'main' into kderusso/esql-match-phrase
kderusso May 30, 2025
9591c18
Realized the scoring test might be flakey because how it was written,…
kderusso May 30, 2025
1cc6eba
PR feedback
kderusso Jun 2, 2025
77c9fbf
PR feedback
kderusso Jun 2, 2025
6983392
[CI] Auto commit changes from spotless
elasticsearchmachine Jun 2, 2025
f94faeb
Add check to MatchPhrase tests
kderusso Jun 3, 2025
553fb02
Merge from main and resolve merge conflicts
kderusso Jun 3, 2025
373c8eb
Fix merge errors
kderusso Jun 3, 2025
b9410f4
[CI] Auto commit changes from spotless
elasticsearchmachine Jun 3, 2025
7db150f
Test generated docs
kderusso Jun 3, 2025
1051aed
Merge branch 'main' into kderusso/esql-match-phrase
kderusso Jun 4, 2025
e680538
Add additional verifier tests
kderusso Jun 4, 2025
39839e4
Merge from main
kderusso Jun 4, 2025
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/127661.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 127661
summary: Add MATCH_PHRASE
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.

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.

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,4 +1,7 @@
* [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] [`QSTR`](../../functions-operators/search-functions.md#esql-qstr)
% * [preview] [`TERM`](../../functions-operators/search-functions.md#esql-term)
% * [preview] [
`TERM`](../../functions-operators/search-functions.md#esql-term)
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,46 @@ mapped_pages:

# {{esql}} Search functions [esql-search-functions]

Use these functions for [full-text search](docs-content://solutions/search/full-text.md) and [semantic search](docs-content://solutions/search/semantic-search/semantic-search-semantic-text.md).
Use these functions
for [full-text search](docs-content://solutions/search/full-text.md)
and [semantic search](docs-content://solutions/search/semantic-search/semantic-search-semantic-text.md).

Get started with {{esql}} for search use cases with our [hands-on tutorial](docs-content://solutions/search/esql-search-tutorial.md).
Get started with {{esql}} for search use cases with
our [hands-on tutorial](docs-content://solutions/search/esql-search-tutorial.md).

Full text functions can be used to match [multivalued fields](/reference/query-languages/esql/esql-multivalued-fields.md). A multivalued field that contains a value that matches a full text query is considered to match the query.
Full text functions can be used to
match [multivalued fields](/reference/query-languages/esql/esql-multivalued-fields.md).
A multivalued field that contains a value that matches a full text query is
considered to match the query.

Full text functions are significantly more performant for text search use cases on large data sets than using pattern matching or regular expressions with `LIKE` or `RLIKE`
Full text functions are significantly more performant for text search use cases
on large data sets than using pattern matching or regular expressions with
`LIKE` or `RLIKE`

See [full text search limitations](/reference/query-languages/esql/limitations.md#esql-limitations-full-text-search) for information on the limitations of full text search.
See [full text search limitations](/reference/query-languages/esql/limitations.md#esql-limitations-full-text-search)
for information on the limitations of full text search.

{{esql}} supports these full-text search functions:

:::{include} ../_snippets/lists/search-functions.md
:::


:::{include} ../_snippets/functions/layout/kql.md
:::

:::{include} ../_snippets/functions/layout/match.md
:::

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

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

% TERM is currently a hidden feature
% To make it visible again, uncomment this and the line in lists/search-functions.md
% To make it visible again, uncomment this and the line in
lists/search-functions.md
% :::{include} ../_snippets/functions/layout/term.md
% :::

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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 @@ -129,6 +129,11 @@ public MatchPhraseQueryBuilder zeroTermsQuery(ZeroTermsQueryOption zeroTermsQuer
return this;
}

public MatchPhraseQueryBuilder zeroTermsQuery(String zeroTermsQueryString) {
ZeroTermsQueryOption zeroTermsQueryOption = ZeroTermsQueryOption.readFromString(zeroTermsQueryString);
return zeroTermsQuery(zeroTermsQueryOption);
}

public ZeroTermsQueryOption zeroTermsQuery() {
return this.zeroTermsQuery;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public static ZeroTermsQueryOption readFromStream(StreamInput in) throws IOExcep
throw new ElasticsearchException("unknown serialized type [" + ord + "]");
}

public static ZeroTermsQueryOption readFromString(String input) {
for (ZeroTermsQueryOption zeroTermsQuery : ZeroTermsQueryOption.values()) {
if (zeroTermsQuery.name().equalsIgnoreCase(input)) {
return zeroTermsQuery;
}
}
throw new ElasticsearchException("unknown serialized type [" + input + "]");
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(this.ordinal);
Expand Down
Loading
Loading