1

I am using bulk_get(/{db}/_bulk_get) API from Couchbase to get bulk documents, below is my code

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

But it seems like Couchbase doesn't returning updated result, when i try to retrieve single document it return updated results. So is there any way to force update the result?

DaveR
  • 9,540
  • 3
  • 39
  • 58
rash
  • 91
  • 7
  • 1
    Curious as to why you go through the trouble of using REST API when you could use a python client. http://docs.couchbase.com/developer/python-2.0/bulk-operations.html (is this couchbase or couchbase mobile?) – FuzzyAmi Sep 02 '15 at 16:56
  • 1
    You are using a unsupported API (_bulk_get & _all_docs). To access the documents through a supported API please use the python SDK. – Paddy Sep 02 '15 at 21:51

0 Answers0