On this page



Filters its input documents and outputs only those documents that match its query filter condition.

The match action cannot be in the first stage of a pipeline. The stage preceding the match action stage must output documents; for example, a built-in action literal stage.

The match action stage has the following syntax:

{ "service": "", "action": "match", "args": { "expression": <query filter document> } }

The match action has the following argument:

Argument Type Description
expression document Query filter against which to compare each incoming document. Specify the filter as a JSON document. Filter expression can include MongoDB query expressions as well as variables (%%vars) defined in the stage.


Consider the following pipeline of two stages:

  {"service": "", "action": "literal", "args": {"items": [{"x": 5, "y": 10}, {"x": 10, "y": 10}]}},
  {"service": "", "action": "match", "args": {"expression": {"x": {"%gt": 5}}}}

Stage1: The literal stage outputs the following documents:

{"x": 5, "y": 10}
{"x": 10, "y": 10}

The two documents are input to Stage 2.

Stage2: The match stage applies the filter to the input documents and outputs only the document that matches the condition:

{x: 10, y: 10}
←   null project  →