我在Rethink中有一系列现有文档.他们都有一个ID字段.我想要做的基本上是这个(在javascript中):
r.table('my_table').replace(myArrayOfDocuments);
Run Code Online (Sandbox Code Playgroud)
当我尝试时,我得到一个错误说: Inserted value must be an OBJECT (got ARRAY)
有任何想法吗?
这是一个示例文档:
{
"id": 12345,
"links": [
{
url: "http://something.com",
created: 1234567890987
},
{
url: "http://somethingelse.com",
created: 1234567891548
},
{
url: "http://somethingweird.com",
created: 1234567898555
}
]
}
Run Code Online (Sandbox Code Playgroud)
该created
字段只是一个unix时间戳.我希望能够created
在links
数组的每个项目中包含的字段上运行索引查询.我不知道如何去做(或者如果可能的话).例如,由于表中有大量文档(大约7百万),因此该查询甚至无法完成:
r.db('test').table('very_large_table')
.filter(function(row) {
return row('links').filter(function(link) {
return link('created').ge(1425293715379)
}).isEmpty().not()
})
.count()
Run Code Online (Sandbox Code Playgroud)
编辑由于数据集太大,我放弃了聚合策略的实时查询.现在,我们没有尝试按要求查询此数据,而是使用消息队列和数据聚合作业来压缩这些数据,因此它已经处理并且查询速度超快.再次感谢您的帮助!
rethinkdb ×2