I would like to have what MongoDB Compass produced as a BsonArray for the C# driver be just another step more.
Essentially MongoDB Compass created a BsonArray of BsonDocuments for C# that included within it my $searchBeta query.
However I do not find documentation on how to execute this $searchBeta statement laid out in a bunch of BsonDocuments within my BsonArray.
How do I take the next step and take what is essentially what MongoDB Compass created for me and execute and get results back from the MongoDB Driver for C#?
Hi @Jeff_Lee, welcome!
$searchBeta is an aggregation pipeline stage, and you should be able to construct aggregation pipeline stages using MongoDB .NET/C# with BsonDocument array. For example:
var pipeline = new BsonDocument[]{
new BsonDocument{ {"$searchBeta", new BsonDocument{{"<operator>", "<specifications>"}}} },
};
var agg = collection.Aggregate<BsonDocument>(pipeline);
If you have further questions, could you elaborate your questions with examples please ?
Regards,
Wan.
1 Like