我有一个具有以下结构的数组:
Array
(
[526e379cdc178e5f8fb31e84] => Array
(
[_id] => MongoId Object
(
[$id] => 526e379cdc178e5f8fb31e84
)
[lv] => Array
(
[0] => Array
(
[ln] => Hospital bill review
[pa] => Auditing
)
[1] => Array
(
[ln] => Fraud
[pa] => -1
)
[2] => Array
(
[ln] => Type of detected/predicted fraud
[pa] => Fraud
)
[3] => Array
(
[ln] => Individual fraud
[pa] => Type of detected/predicted fraud
)
)
[pn] => AU2000240683A2
)
[526e379bdc178e5f8fb31e0d] => Array
(
[_id] => MongoId Object
(
[$id] => 526e379bdc178e5f8fb31e0d
)
[lv] => Array
(
[0] => Array
(
[ln] => Claim processing
[pa] => Methods for detecting/predicting fraud
)
[1] => Array
(
[ln] => Claim cost management(settlement)
[pa] => -1
)
[2] => Array
(
[ln] => Multiple payer options/ liability computation
[pa] => Claim cost management(settlement)
)
)
[pn] => AU2001239752B2
)
)
我正在使用以下聚合函数:
$out = $collection->aggregate(array(
array('$unwind'=>'$lv'),
array('$match' => array('lv.pa'=>-1)),
array('$group'=>array(_id=>'$lv.ln')),
)
);
print_r($out);
它给出了以下结果:
Array
(
[result] => Array
(
[0] => Array
(
[_id] => Fraud
)
[1] => Array
(
[_id] => Claim cost management(settlement)
)
)
[ok] => 1
)
但我想要下面的结构而不使用 PHP。因为我已经使用 PHP 实现了它。
Array
(
[result] => Array
(
[0] => Fraud
[1] => Claim cost management(settlement)
)
[ok] => 1
)
提前致谢。