Skip to content

[FEATURE] Support match_phrase with push down when calcite is enabled #3668

Closed

Description

@penghuo

Is your feature request related to a problem?

###
PUT {{baseUrl}}/ppl_test_logs
Content-Type: application/x-ndjson

{
    "mappings": {
        "properties": {
            "date": {
                "type": "date_nanos" 
            },         
            "message": {
                "type": "text"
            }         
        }
    }
}

###
POST {{baseUrl}}/ppl_test_logs/_doc
Content-Type: application/x-ndjson

{
    "date":  1420070400, 
    "message": "This is a text field 1"
}

###
POST {{baseUrl}}/ppl_test_logs/_doc
Content-Type: application/x-ndjson

{
    "date":  1420070400,    
    "message": "This is a text field 2"
}
  • explain query, match_phrase is not pushdown to DSL query when calcilte enabled.
###
POST {{baseUrl}}/_plugins/_ppl/_explain
Content-Type: application/x-ndjson

{
    "query": "source = ppl_test_logs | where match_phrase(message, 'field 2') | fields body"
}

{
  "root": {
    "name": "ProjectOperator",
    "description": {
      "fields": "[body]"
    },
    "children": [
      {
        "name": "OpenSearchIndexScan",
        "description": {
          "request": "OpenSearchQueryRequest(indexName=ppl_test_logs, sourceBuilder={\"from\":0,\"size\":10000,\"timeout\":\"1m\",\"query\":{\"match_phrase\":{\"message\":{\"query\":\"field 2\",\"slop\":0,\"zero_terms_query\":\"NONE\",\"boost\":1.0}}},\"_source\":{\"includes\":[\"body\"],\"excludes\":[]},\"sort\":[{\"_doc\":{\"order\":\"asc\"}}]}, needClean=true, searchDone=false, pitId=null, cursorKeepAlive=null, searchAfter=null, searchResponse=null)"
        },
        "children": []
      }
    ]
  }
}

What solution would you like?
Support match_phrase with push down when calcite is enabled

Activity

  1. added
    enhancement
    calcite
    PPL
    on May 23, 2025
  2. added
    performance
    and removed on May 27, 2025
  3. penghuo commented on May 29, 2026

    @penghuo
    CollaboratorAuthor

    Verified fixed on current main (built at commit 585fa9e53, OpenSearch 3.7.0-SNAPSHOT) with plugins.calcite.enabled=true.

    Reproduced the scenario from the issue:

    PUT /ppl_test_logs   (mappings: date=date_nanos, message=text)
    POST /ppl_test_logs/_doc  {"date":1420070400,"message":"This is a text field 1"}
    POST /ppl_test_logs/_doc  {"date":1420070400,"message":"This is a text field 2"}
    
    PUT /_cluster/settings  {"transient":{"plugins.calcite.enabled": true}}
    

    Explain output now shows match_phrase pushed down into both the PushDownContext and the actual DSL sourceBuilder:

    {
      "calcite": {
        "physical": "CalciteEnumerableIndexScan(table=[[OpenSearch, ppl_test_logs]], PushDownContext=[[PROJECT->[message], FILTER->match_phrase(MAP('field', $0), MAP('query', 'field 2':VARCHAR)), LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={\"from\":0,\"size\":10000,\"timeout\":\"1m\",\"query\":{\"match_phrase\":{\"message\":{\"query\":\"field 2\",\"slop\":0,\"zero_terms_query\":\"NONE\",\"boost\":1.0}}},\"_source\":{\"includes\":[\"message\"]}}, requestedTotalSize=10000, pageSize=null, startFrom=0)])"
      }
    }

    Query also returns the expected single row ("This is a text field 2"). Closing.

  4. moved this from Not Started to Done in PPL Trackeron May 29, 2026
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

    PPLcalciteenhancementperformance

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions