简体   繁体   中英

How to get distinct records applying '$in' while query in Mongo DB Java

there are duplicates records for each id in MongoDB. I am querying multiple ids using $in.

I want the unique record for each id.

Imo you should look at mongodb aggregation framework, or its implementation in java. Please provide json example of what you're expecting, for more precise answer If you just want distinct id's, use distinct function db.collection.distinct("id") https://docs.mongodb.com/manual/reference/method/db.collection.distinct/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM