Skip to content
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

Support match_phrase function in SQL/PPL query engine #185

Closed
6 tasks
chloe-zh opened this issue Aug 20, 2021 · 4 comments · Fixed by #604
Closed
6 tasks

Support match_phrase function in SQL/PPL query engine #185

chloe-zh opened this issue Aug 20, 2021 · 4 comments · Fixed by #604

Comments

@chloe-zh
Copy link
Contributor

chloe-zh commented Aug 20, 2021

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")
MaxKsyunz referenced this issue in Bit-Quill/opensearch-project-sql Apr 28, 2022
Yury-Fridlyand referenced this issue in Bit-Quill/opensearch-project-sql May 4, 2022
…ch-project-sql into dev-match_phrase-#185

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
@MaxKsyunz
Copy link
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?

@joshuali925
Copy link
Member

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

@MaxKsyunz
Copy link
Collaborator

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

match_phrase.demo-web.mp4

MaxKsyunz referenced this issue in Bit-Quill/opensearch-project-sql May 16, 2022
…h_phrase-#185-legacy-update

# Conflicts:
#	core/src/main/java/org/opensearch/sql/expression/function/BuiltinFunctionName.java
#	core/src/main/java/org/opensearch/sql/expression/function/OpenSearchFunctions.java
#	docs/user/dql/functions.rst
#	docs/user/ppl/functions/relevance.rst
#	opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilder.java
#	sql/src/main/antlr/OpenSearchSQLParser.g4
MaxKsyunz referenced this issue in Bit-Quill/opensearch-project-sql May 21, 2022
@acarbonetto
Copy link
Collaborator

fixed by: #604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants