0

2 つの配列型 (mongo ドキュメントの属性) に Mongo の $unwind 演算子を適用する必要がある、興味深い使用例があります。

2 つの列挙型でフィルタリングしたい例を次に示します。範囲(1000-100000)

複数の演算子を $unwind して、単一の集計パイプラインでそれらをフィルタリングできますか

               db["XXXXXXX"].aggregate( { $unwind : { "$host.config.storageDevice.scsiLun", "$host.config.storageDevice.scsiLun.capacity.block" } }, 
                               { $match : { "host.config.storageDevice.scsiLun.lunType" : "cdrom"  , "host.config.storageDevice.scsiLun.capacity.block" : { $gte : 60000 } , "managedObject" : "host" } } , 
                               { $project : { "host.name" : 1 , "host.config.storageDevice.scsiLun.devicePath" : 1 , "host.config.storageDevice.scsiLun.capacity.blockSize" : 1 , "host.config.storageDevice.scsiLun.capacity.block" : 1 , "host.config.storageDevice.scsiLun.ssd" : 1 , "host.config.storageDevice.scsiLun.uuid" : 1 , "host.config.storageDevice.scsiLun.lunType" : 1 , "_id" : 0  }} )

また

複合集計操作単位の結果を別の集計単位に連鎖できますか

               db["XXXXXXX"].aggregate( { $unwind : "$host.config.storageDevice.scsiLun" }, 
               { $match : { "host.config.storageDevice.scsiLun.lunType" : "cdrom"  , "managedObject" : "host" } } , 
               { $project : { "host.name" : 1 , "host.config.storageDevice.scsiLun.devicePath" : 1 , "host.config.storageDevice.scsiLun.capacity.blockSize" : 1 , "host.config.storageDevice.scsiLun.capacity.block" : 1 , "host.config.storageDevice.scsiLun.ssd" : 1 , "host.config.storageDevice.scsiLun.uuid" : 1 , "host.config.storageDevice.scsiLun.lunType" : 1 , "_id" : 0  }},
               { $unwind : "$host.config.storageDevice.scsiLun.capacity.blockSize" },
               { $match : { "host.config.storageDevice.scsiLun.capacity.blockSize" : { $gte : 8000000 } } },
               { $project : { "host.name" : 1 , "host.config.storageDevice.scsiLun.devicePath" : 1 , "host.config.storageDevice.scsiLun.capacity.blockSize" : 1 , "host.config.storageDevice.scsiLun.capacity.block" : 1 , "host.config.storageDevice.scsiLun.ssd" : 1 , "host.config.storageDevice.scsiLun.uuid" : 1 , "host.config.storageDevice.scsiLun.lunType" : 1 , "_id" : 0  }} 
4

0 に答える 0