shard key specification












0















I have a document like so:



{
"_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
}
]
}
]
}


I want to shard by teams.name. I tried doing:



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


But I get the error that the shard key can only be 1 or hashed. Does anyone know how to to enable sharding using an embedded field?










share|improve this question



























    0















    I have a document like so:



    {
    "_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
    }
    ]
    }
    ]
    }


    I want to shard by teams.name. I tried doing:



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


    But I get the error that the shard key can only be 1 or hashed. Does anyone know how to to enable sharding using an embedded field?










    share|improve this question

























      0












      0








      0








      I have a document like so:



      {
      "_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
      }
      ]
      }
      ]
      }


      I want to shard by teams.name. I tried doing:



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


      But I get the error that the shard key can only be 1 or hashed. Does anyone know how to to enable sharding using an embedded field?










      share|improve this question














      I have a document like so:



      {
      "_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
      }
      ]
      }
      ]
      }


      I want to shard by teams.name. I tried doing:



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


      But I get the error that the shard key can only be 1 or hashed. Does anyone know how to to enable sharding using an embedded field?







      mongodb sharding






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 11 mins ago









      tom dinhtom dinh

      325




      325






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f232967%2fshard-key-specification%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f232967%2fshard-key-specification%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Ronny Ackermann

          Köttigit

          MySQL 8.0.15 starts normally but any connection hangs