I am using the Mongo Aggregation Framework using the Java MongoDB driver, version 3.3. I have an aggregagtion pipeline, that is merely collection of type List
For mongodb-java API 3.4, the constant MongoClient.DEFAULT_CODEC_REGISTRY
is no more accessible directly, it's a private member. There is a static method CodecRegistry getDefaultCodecRegistry()
which returns the same constant.
Another point, BsonDocument.toString()
internally does a toJson()
with default JsonWriterSettings
. In order to see the Shell equivalent of Query, use it like below:
public void logQuery(Bson filter) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"filter query: " + filter.toBsonDocument(BsonDocument.class, MongoClient.getDefaultCodecRegistry())
.toJson(new JsonWriterSettings(JsonMode.SHELL)));
}
}