Skip to content

Support match_phrase function in SQL/PPL query engine #185

Closed

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")

Activity

  1. added a commit that references this issue on May 4, 2022
  2. MaxKsyunz commented on May 5, 2022

    @MaxKsyunz
    Collaborator

    @penghuo, should the PPL parser support alternative spelling of match_phrase like matchphrase?

    For example, are queries like source=index | where matchphrase(field, 'text') valid?

  3. joshuali925 commented on May 6, 2022

    @joshuali925
    Member

    @MaxKsyunz match_pharse should be enough, i don't think PPL functions support alternative spellings (there is date_format() but not dateformat())

  4. MaxKsyunz commented on May 12, 2022

    @MaxKsyunz
    Collaborator

    @joshuali925, here's a demo of the changes in PR #604

    match_phrase.demo-web.mp4
  5. added 2 commits that reference this issue on May 16, 2022
  6. acarbonetto commented on Aug 4, 2022

    @acarbonetto
    Collaborator

    fixed by: #604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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