how to get all keys from couchbase?

家住魔仙堡 提交于 2019-12-23 21:14:45

问题


i use python language to get all keys from couchbase, the following is my code;

function(doc, meta){
    emit(null, meta.id);
}

this is view in "namedb" bucket;

from couchbase import Couchbase
db = Couchbase.connect(bucket="namedb", host="192.168.1.170", port=8091)
name = 'key'
view = 'all'
skip=0
limit = 10000
fd = open("name.txt", "a", 0)
num = 1000000
while skip < num:
    result = db.query(name, view, use_devmode = False, limit = limit, skip = skip)
    for row in result:
        fd.write(row.value + '\n')
    skip += limit
fd.close()

there have 1000000 documents in this bucket, and when skip = 210000, result variable will get a empty result;

i excute this program many times; when skip = 210000, db.query() function always return empty result; how can i resolve it? how can i get all keys in this bucket? thank you

来源:https://stackoverflow.com/questions/27040667/how-to-get-all-keys-from-couchbase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!