Skip to content

Instantly share code, notes, and snippets.

@metanav
Last active December 8, 2015 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metanav/ace4e5de7aecd556c5a8 to your computer and use it in GitHub Desktop.
Save metanav/ace4e5de7aecd556c5a8 to your computer and use it in GitHub Desktop.
<?php
$ab = $this->dm->getDocumentCollection('Document\Test')->createAggregationBuilder();
if (is_array($filter)) {
/* Here $filter is an array which could be $qb->getQuery()->getQuery()['query']
* or manually crafted
* example [ '$and' => [ 'name' => 'keyword'] ]
*/
$ab->match(); // <-- how to pass query array to match stage?
} else {
$ab->match()->text($filter);
}
// more complex things like group, redact, sort are happening and aggregation builder does really well here
$results = $ab->execute();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment