I am new to mongodb and need an equivalent code in java for the below
db.asset.aggregate([{
$unwind : '$asset'
}, {
$match : {
'asset.status' : {
$in : ['1', '2', '3']
},
'asset.siteid' : {
$in : ['123']
}
}
}
]).pretty()
I tried the following but it didn't help-out
DBObject unwind = new BasicDBObject("$unwind", "$dp.asset");
DBObject match = BasicDBObjectBuilder.start().push("$match")
.push("dp.asset.status").add("$in", ['ACTIVE', 'LIMITEDUSE', 'OPERATING'])
.push("dp.asset.siteid").add("$in", ['BEDFORD']).get();
AggregationOutput aggr = collection.aggregate(Arrays.asList(unwind, match));
Note : i am using mongodb 3.4.1