次の構造の配列があります。
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
)
前もって感謝します。