Reputation: 142
I have the following query and I want the first result to be hydrated. This is what I tried:
$builder = $dm->createAggregationBuilder(\Documents\Jobs::class);
$builder
->facet()
->field('carpenterJobs')
->pipeline(
$dm->createAggregationBuilder(\Documents\Jobs::class)
->hydrate($this->getEntityName(\Documents\Jobs::class))
->match()
->field('name')
->equals('carpenter');
)
->field('cleanerJobs')
->pipeline(
$dm->createAggregationBuilder(\Documents\Jobs::class)
->match()
->field('name')
->equals('cleaner');
)
;
But when I execute this, the results are not hydrated. Below is the Jobs entity:
/**
* @QueryResultDocument
* @Document(repositoryClass="...")
*/
class Jobs
{
/**
* @Id
*/
private $id;
/**
* @Field(type="string")
* @Index(unique=true, order="asc")
*/
private $name;
...
}
I also tried to hydrate the $builder
but it returns an error saying Undefined index: _id
. Executing the 'carpenterJobs' query by itself, without being inside a faucet, I can return hydrated results.
Upvotes: 0
Views: 1026