[Solved] How to represent distinct query of mongo db in java language [closed]


Considering item.sku is of a String Type, you can fire your distinct query like this:

BasicDBObject filter = new BasicDBObject();
filter.put( "dept", "A" );

MongoCursor<String> c = db.getCollection("inventory").distinct("item.sku", filter, String.class).iterator();

Hope this helps.

solved How to represent distinct query of mongo db in java language [closed]