The $match
stage accepts a JSON document that specifies query conditions on indexed properties to filter the resulting document list. This document list is then passed onto the next stage of the pipeline or returned as the response if it is the last stage of the pipeline.
{"$match": {<query conditions>}}
See Query Operators for more details and examples of available conditions.
Examples
In this example, we have just a one stage pipeline where we match accounts by the first name in a custom script. This returns a result set of accounts filtered to only include Kevins.
GET /accounts?pipeline=[{"$match": {"name.last": {"$regex": "/^s/i"}}}]
{
"data": [
{
"_id": "5888b91d35f8c91536c6ddea",
"access": 6,
"c_enrollments": [],
"c_study_groups": [],
"created": "2017-01-25T14:41:33.297Z",
"email": "[email protected]",
"favorite": false,
"gender": "m",
"inherited_roles": [
"000000000000000000000007",
"000000000000000000000006"
],
"key": {
"fingerprint": "8e53d430-e30c-11e6-aaeb-99172490c13b",
"secret": "heBcf2Wgh6hjezADTAc88wHJNGcJgwUd"
},
"locale": "en_US",
"locked": false,
"mobile": "+12223334449",
"name": {
"first": "John",
"last": "Silver"
},
"object": "account",
"roles": [
"000000000000000000000004"
],
"shared": false,
"state": "verified",
"updated": "2017-01-25T14:42:54.970Z",
"updater": {
"_id": "5888b91d35f8c91536c6ddea",
"object": "account",
"path": "/accounts/5888b91d35f8c91536c6ddea"
}
}
],
"hasMore": false,
"object": "list"
}