Skip to content

Support match_phrase function in SQL/PPL query engine #185

@chloe-zh

Description

@chloe-zh

Related design is presented in issue #182

Todo list

  • Support the match_phrase functionality by pushing it down to the search engine
  • Enable match_phrase function in SQL and PPL syntax and parser, including all the available parameters
  • Make sure the function in new engine is compatible with the old engine support (including match_phrase and matchphrase functions in old engine)
  • Add unit tests. (Unit tests are mandatory for all code changes.)
  • Add integration test cases for match_phrase
  • Update user manual

Function details

The match_phrase function maps to the match phrase query used in search engine. This query analyzes the text and creates a phrase query out of the analyzed text.

Syntax:
match_phrase(field_expression, query_expression[, option=<option_value>]*)

Available options:

  • analyzer
  • zero_terms_query

Sample queries:

# Search query 1
GET my_index/_search
{
  "query": {
    "match_phrase": {
      "message": "this is a test"
    }
  }
}

# SQL
SELECT * FROM my_index WHERE match_phrase(message, "this is a test")

# PPL 
source=my_index | match type=match_phrase field=message query="this is a test"


# Search query 2
GET my_index/_search
{
  "query": {
    "match_phrase": {
      "message": {
        "query": "this is a test",
        "analyzer": "my_analyzer"
      }
    }
  }
}

# SQL
SELECT* FROM my_index WHERE match_phrase(message, "this is a test", analyzer="my_analyzer") 

# PPL 
source=my_index | where match_phrase(message, "this is a test", analyzer="my_analyzer")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions