批量获取Couchbase API没有返回更新结果

时间:2015-09-02 15:20:19

标签: python flask couchbase couchbase-view

我正在使用Couchbase的bulk_get(/ {db} / _ bulk_get)API来获取批量文档,下面是我的代码

def getBulkJsonDoc(doc_ids):
    """
    @purpose: gets a bulk docs from couchbase
    """
    r = requests.post(base_url + '_all_docs', json.dumps({'keys' : doc_ids})).json()
    body = {'docs' : []}
    for row in r['rows']:
        if 'error' in row:
            continue #Doc not found
        doc         = {}
        doc['rev']  = row['value']['rev']
        doc['id']   = row['id']
        body['docs'].append(doc)


    r       = requests.post(base_url + '_bulk_get', json.dumps(body))
    docs    = []
    for l in r.content.split('\n'):
        try:
            j = json.loads(l)
            docs.append(j)
        except Exception as e:
            pass

    return docs

但似乎Couchbase没有返回更新结果, 当我尝试检索单个文档时,它返回更新的结果。那么有什么方法可以强制更新结果吗?

0 个答案:

没有答案