【发布时间】:2015-04-03 02:31:22
【问题描述】:
在 couchbase 中,假设一个文档有一个字段,其中包含一组引用其他文档的键
{
"some_ids": ["otherdoc1", "otherdoc2", "otherdoc3"]
}
这两种用于检索some_ids 字段中的所有文档的解决方案中哪一种具有最佳性能?
-
List<JsonDocument> foundDocs = Observable .just("otherdoc1", "otherdoc2", "otherdoc3") .flatMap(new Func1<String, Observable<JsonDocument>>() { @Override public Observable<JsonDocument> call(String id) { return bucket.async().get(id); } }) .toList() .toBlocking() .single(); -
创建一个设计视图,然后使用
startKey和endKey检索其索引的子集// Map function function(doc, meta) { if (doc.type == 'otherdoc') { emit(meta.id, doc); } } // ViewQuery (in a java method) ViewQuery.from('designOther', 'viewOther') .startKey('otherdoc1') .endKey('otherdoc2');
【问题讨论】: