首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >切分键规格

切分键规格
EN

Database Administration用户
提问于 2019-03-24 23:00:42
回答 1查看 30关注 0票数 0

我有一份这样的文件:

代码语言:javascript
复制
{
    "_id" : ObjectId("52f29f91ddbd75540aba6dae"),
    "teams" : [
        {
            "name" : "Washington Bullets",
            "score" : 100,
            "home" : false,
            "won" : 1,
            "players" : [
                {
                    "player" : "Jeff Ruland",
                    "pts" : 19
                },
                {
                    "player" : "Cliff Robinson",
                    "pts" : 22
                },
                {
                    "player" : "Gus Williams",
                    "pts" : 21
                },
                {
                    "player" : "Jeff Malone",
                    "pts" : 18
                },
                {
                    "player" : "Charles Jones",
                    "pts" : 4
                },
                {
                    "player" : "Dan Roundfield",
                    "pts" : 2
                },
                {
                    "player" : "Perry Moss",
                    "pts" : 7
                },
                {
                    "player" : "Dudley Bradley",
                    "pts" : 0
                },
                {
                    "player" : "Darren Daye",
                    "pts" : 5
                },
                {
                    "player" : "Tom McMillen",
                    "pts" : 2
                },
                {
                    "player" : "Manute Bol",
                    "pts" : 0
                }
            ]
        },
        {
            "name" : "Atlanta Hawks",
            "score" : 91,
            "home" : true,
            "won" : 0,
            "players" : [
                {
                    "player" : "Dominique Wilkins",
                    "pts" : 32
                },
                {
                    "player" : "Tree Rollins",
                    "pts" : 9
                },
                {
                    "player" : "Cliff Levingston",
                    "pts" : 8
                },
                {
                    "player" : "Spud Webb",
                    "pts" : 12
                },
                {
                    "player" : "Kevin Willis",
                    "pts" : 13
                },
                {
                    "player" : "Randy Wittman",
                    "pts" : 6
                },
                {
                    "player" : "Scott Hastings",
                    "pts" : 4
                },
                {
                    "player" : "Lorenzo Charles",
                    "pts" : 4
                },
                {
                    "player" : "Sedric Toney",
                    "pts" : 0
                },
                {
                    "player" : "Ray Williams",
                    "pts" : 0
                },
                {
                    "player" : "Jon Koncak",
                    "pts" : 3
                }
            ]
        }
    ]
}

我想用teams.name碎。我试着做:

代码语言:javascript
复制
sh.shardCollection("finalNBA.list", {teams:{name:1}})

但我得到的错误是,碎片键只能是1或散列。有人知道如何使用嵌入式字段启用分片吗?

EN

回答 1

Database Administration用户

发布于 2019-03-25 03:59:30

尝试使用,这里的关键是点符号。

sh.shardCollection("finalNBA.list", {"teams.name":1}})

确保您已经为test.name字段创建了索引。

票数 0
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/232967

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档