这是BSON文件。我只想要那些属性length
大于零的条目
/* 1 */
{
"_id" : "http://exhentai.org",
"length" : 0,
"value" : ""
}
/* 2 */
{
"_id" : "http://vuclip.com",
"length" : 77,
"value" : "vuclip scroll learn official weve launched close news team pressroom linkedin"
}
/* 3 */
{
"_id" : "http://hbogo.com",
"length" : 174,
"value" : "hbo hbo anywhere hbo enjoy instant unlimited access every episode every season best hbo shows movies comedy sports documentaries hbo free subscription participating providers"
}
所以输出应该是
/* 2 */
{
"_id" : "http://vuclip.com",
"length" : 77,
"value" : "vuclip scroll learn official weve launched close news team pressroom linkedin"
}
/* 3 */
{
"_id" : "http://hbogo.com",
"length" : 174,
"value" : "hbo hbo anywhere hbo enjoy instant unlimited access every episode every season best hbo shows movies comedy sports documentaries hbo free subscription participating providers"
}
我尝试了什么
db.coll.aggregate([
{$project: {
Text:
{
$cond: { if: { $gte: [ "$length", 20 ] }, then: "$value" }
}
_id : 0
}}
])