Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我为 mongodb 集合中的键“userId”启用了基于散列的分片。是否可以获得“userId”散列值介于“abcd”和“cdef”之间的所有文档?
谢谢!
我发现的一种方法是使用以下查询:
db.mycollection.find({ "$and": [ {_id: {"$gt": -5012941854059245285}}, {_id : {"$lt": -4712634714892678072}} ]}).hint({_id: "hashed"})
其中长数字是_id的散列值。它对我有用,但这是最好的方法吗?我可以确定它将与即将发布的 mongodb 一起使用吗?