Hi Mukesh
In case of Range based sharding, it’s working fine as I can see range of shard key, but in case of Hashed based sharding, e.g- I hashed on key _id, so now I can see range on hashed value which I can’t find in a document. Please help on this.
By design, hash indexes only support equality matches, and cannot perform range-based queries (https://docs.mongodb.com/manual/indexes/#hashed-indexes). Since MongoDB doesn’t provide a user-facing command to compute the hash, and querying for orphaned documents involve range queries, it is currently not possible (as of MongoDB 3.4.4) to find orphaned documents for collections using hash indexes.
In this case, since orphaned documents are likely to be an outdated version of a document (or possibly even a non-existent document), the command cleanupOrphaned is the recommended method to remove orphaned documents.
Having said that, if a “dry-run” of cleanupOrphaned is what you require, please upvote SERVER-17013, and please comment on the ticket with a detailed description your use case.
Best regards,
Kevin