【发布时间】:2015-12-19 10:20:06
【问题描述】:
假设我有一个表格,其中包含以下文档:
{
"country": 1,
"merchant": 2
"product": 123,
...
}
是否可以将所有文档分组为最终的 json 结构,例如:
[
{
<country_id>: {
<merchant_id>: {
<product_id>: <# docs with this product id/merchant_id/country_id>,
... (other product_id and so on)
},
... (other merchant_id_id and so on)
},
... (other country_id and so on)
]
如果是的话,最好和最有效的方法是什么? 我有超过一百万个这样的文档,在 4 个带有强大服务器的分片上(每个 22 Gb 缓存)
我已经尝试过了(目前在数据资源管理器中,在 JS 中):
r.db('foo')
.table('bar')
.indexCreate('test1', function(d){
return [d('country'), d('merchant'), d('product')]
})
然后
r.db('foo')
.table('bar')
.group({index: 'test1'})
但是数据浏览器似乎挂了,你可以看到仍在处理它...
【问题讨论】:
标签: rethinkdb rethinkdb-python rethinkdb-javascript