2017-12-19 11 views
0

sh.splitAt()セットのドキュメントクエリに制限は、なぜこれがエラーにつながる:のMongoDBシャーディング()

db.cases.createIndex({"code":1},{unique:true}) 
sh.shardCollection("casemanagement.cases",{"code":1}) 
sh.splitAt("casemanagement.cases",{code:{$regex:/...........[4-6]./}}) 

がエラー:

new split key {code:{$regex:/...........[4-6]./} is not valid for shard key pattern code {1.0} 

関連する3.4のソースは、です。cluster_split_cmd.cpp 228、shard_key_pattern_test.cppです。なぜ "コード"はシャードキーなので、ShardKeyPatternは価値の面で気になるのですか?

答えて

0

MongoDBシャーディングはチャンク分割に基づいています。各チャンクには、定義された最大キーと最小キーの範囲があります。したがって、分割は、正規表現パターンの代わりに値の範囲のみを受け入れることは驚くことではありません。私が探していた機能が可能

sh.splitAt(namespace, query) splits the shard at a single point -- a query that identifies one and only one document that may or may not exist in the current collection, moving all documents beyond that point to the new chunk.

:私は今sh.splitAt()は実際に何をするか、どのように最善のことを文書化するために理解

0

)(これはsh.splitAtで文書化されなければならないことに同意します以下の存在しない特徴として特徴付けられる:

sh.cull(namespace, filter) divides the shard using a filter query, where documents that selected by the query are moved to the new chunk, leaving those not selected by the query in the current chunk.

関連する問題