Mongodb复合碎片键与标签感知切分。
环境
mongodb集群。Americas的国家标记,最后两个碎片有一个Europe标记。country, user, domain上是复合的。问题
我正在尝试基于国家的标签感知切分,所以任何带有country: 1的文档都将在前两个切分之间自动切分,而任何带有country: 2的文档都将自动切分到最后两个切分。
Sample Data:`
"_id" : ObjectId("56c4cc2fb086de4769800fe4"), "timestamp" : ISODate("1970-01-01T00:00:00Z"), "user" : "guest", "category" : "Google", "domain" : "google.com", "source" : 1.1.1.1, "destination" : 2.2.2.2, "country" : 1, "__v" : 0`
"_id" : ObjectId("56c4cc2fb086de4769800fe4"), "timestamp" : ISODate("1970-01-01T00:00:00Z"), "user" : "guest2", "category" : "Bing", "domain" : "bing.com", "source" : 2.2.2.2, "destination" : 3.3.3.3, "country" : 2, "__v" : 0`
config.tags:
"_id" : { "ns" : "logs.sitea", "min" : { "country" : "1" } }, "ns" : "logs.sitea", "min" : { "country" : "1" }, "max" : { "country" : "2" }, "tag" : "Americas"`
"_id" : { "ns" : "logs.siteb", "min" : { "country" : "2" } }, "ns" : "logs.siteb", "min" : { "country" : "2" }, "max" : { "country" : "3" }, "tag" : "Europe"`
config.shards:
"_id" : "shard0000", "host" : "1.1.1.1:27019", "tags" : [ "Americas" ]`
"_id" : "shard0001", "host" : "1.1.1.2:27019", "tags" : [ "Americas" ]`
"_id" : "shard0002", "host" : "2.2.2.2:27019", "tags" : [ "Europe" ]`
"_id" : "shard0003", "host" : "2.2.2.3:27019", "tags" : [ "Europe" ]`
sh.status:
"_id" : "logs", "primary" : "shard0002", "partitioned" : true`
logs.sitea`
shard key: { "country" : 1, "user" : 1, "domain" : 1 }
unique: false`
balancing: true`
chunks:`
tag: Americas { "country" : "1" } -->> { "country" : "2"`
"_id" : "logs", "primary" : "shard0002", "partitioned" : true }`
logs.siteb`
shard key: { "country" : 1, "user" : 1, "domain" : 1
unique: false`
balancing: true`
chunks:`
tag: Europe { "country" : "2" } -->> { "country" : "3" }发布于 2016-02-22 16:02:57
我的问题是关于国家代码的双引号。
更新标签解决了我的问题:"_id“:{ "ns”:"logs.sitea","min“:{ "country”:1 },"ns“:"logs.sitea","min”:{ "country“:1 },"max”:{ "country“:2 }," tag”:“America”
https://stackoverflow.com/questions/35485435
复制相似问题