Skip to content

Support match function in SQL/PPL query engine #184

Closed
@chloe-zh

Description

@chloe-zh

Related design is presented in issue #182

Todo list

  • Support the match functionality by pushing it down to the search engine
  • Enable match 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
  • Add unit tests. (Unit tests are mandatory for all code changes.)
  • Add integration test cases for match
  • Update user manual

Function details

The match function maps to the match query used in search engine, to return the documents that match a provided text, number, date or boolean value with a given field.

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

Available options:

  • analyzer
  • auto_generate_synonyms_phrase
  • fuzziness
  • max_expansions
  • prefix_length
  • fuzzy_transpositions
  • fuzzy_rewrite
  • lenient
  • operator
  • minimum_should_match
  • zero_terms_query
  • boost

Sample queries:

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

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

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


# Search query 2
GET my_index/_search
{
  "query": {
    "match": {
      "message": {
        "query": "this is a test",
        "operator": "and"
      }
    }
  }
}

# SQL
SELECT message FROM my_index WHERE match(message, "this is a test", operator=and)

# PPL
search source=my_index | match field=message query="this is a test" operator=and


# Search query 3
GET my_index/_search
{
  "query": {
    "match": {
      "message": {
        "query": "to be or not to be",
        "operator": "and",
        "zero_terms_query": "all"
      }
    }
  }
}

# SQL
SELECT message FROM my_index WHERE match(message, "this is a test", operator=and, zero_terms_query=all)

# PPL
search source=my_index | where match(message, "this is a test", operator=and, zero_terms_query=all)

Metadata

Metadata

Assignees

Labels

PPLPiped processing languageSQLv1.2.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions