【发布时间】:2017-11-23 01:10:37
【问题描述】:
我在 mongodb 中有一个集合: 用户集合
{
_id:xxxxxx,
friendList:[12345,67899,57889],//list of ids of friends
readBooks:[bookid1,bookid2],
wanttoread:[bookid5,bookid6]
}
好友合集
{ _id:12345,
readBooks:[bookid3,bookid5],
wantToread:[bookid1]}
我有另一个集合books,它提供了该 id 的一本书的名称和详细信息。
我想基于readBook 或wanttoread 在mongodb 中为此进行分片。如果他们拥有相同的书籍,则数据将进入同一个分片。
我对此进行了搜索,但找不到基于数组进行分片的方法。有什么办法可以做到吗?还是我需要创建另一个集合,例如
{id: userid or friend id,bookId:bookid}
和基于 bookId 的分片。
【问题讨论】:
-
你不能在atm做多键分片索引
标签: mongodb