ES|QL MATCH_PHRASE function
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Generally available
Stack
9.1+
Generally available since 9.1
Performs a match_phrase query on the specified field or expression.
field- Field or expression that the query will target.
query- Value to find in the provided field or expression.
options-
(Optional) MatchPhrase additional options as function named parameters. See
match_phrasefor more information.
Use MATCH_PHRASE to perform a match_phrase on the specified field or expression. Using MATCH_PHRASE is equivalent to using the match_phrase query in the Elasticsearch Query DSL.
MatchPhrase can be used on text and keyword fields. MatchPhrase is not supported for other field types, like semantic_text, boolean, date, or numeric types.
MatchPhrase can use function named parameters to specify additional options for the
match_phrase query.
All match_phrase query parameters are supported.
MATCH_PHRASE returns true if the provided query matches the row.
MATCH_PHRASE on expressions
The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.
Availability
Planned
We plan to add this functionality in a future Elastic Stack update. Subject to changes.
Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.
This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.
Availability
Generally available
This functionality is generally available and ready for production usage.
Serverless interfaces and procedures might differ from classic Elastic Stack deployments.
MATCH_PHRASE can also search text and keyword expressions that are not backed by an index,
such as computed columns produced by EVAL, STATS, or other commands.
When the target is not an indexed field, the search evaluates by scanning
values row by row, which may be slower on large datasets.
Analyzers, options, and scoring work differently than on an indexed field.
To learn more, refer to runtime search.
Learn more about using ES|QL for search use cases.
| field | query | options | result |
|---|---|---|---|
| keyword | keyword | named parameters | boolean |
| text | keyword | named parameters | boolean |
analyzer- (keyword) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field; if no analyzer is mapped, the index’s default analyzer is used. For expressions not backed by an index, defaults to the values analyzer declared through
TO_TEXT(standardwhen none is declared). slop- (integer) Maximum number of positions allowed between matching tokens. Defaults to 0. Transposed terms have a slop of 2.
zero_terms_query- (keyword) Indicates whether all documents or none are returned if the analyzer removes all tokens, such as when using a stop filter. Defaults to none.
boost-
(float) Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0.
The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Stack
9.1+
Generally available since 9.1
FROM books
| WHERE MATCH_PHRASE(author, "William Faulkner")
| book_no:keyword | author:text |
|---|---|
| 2713 | William Faulkner |
| 2883 | William Faulkner |
| 4724 | William Faulkner |
| 4977 | William Faulkner |
| 5119 | William Faulkner |