def findDoc(store,id): senseiHost = store.broker_host senseiPort = store.broker_port senseiClient = SenseiClient(senseiHost,senseiPort) req = SenseiRequest() sel = SenseiSelection("uid") sel.addSelection(str(id)) req.count = 1 req.fetch = True req.selections = [sel] res = senseiClient.doQuery(req) doc = None if res.numHits > 0: if res.hits and len(res.hits) > 0: hit = res.hits[0] doc = hit.srcData return doc
def find_doc(store,id): senseiHost = store.broker_host senseiPort = store.broker_port senseiClient = SenseiClient(senseiHost,senseiPort) req = SenseiRequest() sel = SenseiSelection("_uid") sel.addSelection(str(id)) req.count = 1 req.fetch_stored = True req.selections['_uid'] = sel res = senseiClient.doQuery(req) doc = None if res.numHits > 0: if res.hits and len(res.hits) > 0: hit = res.hits[0] doc = hit.get('srcdata') return doc
def getDoc(self, id): """Retrieve a document based its document ID.""" if not id: return None req = SenseiRequest() sel = SenseiSelection("_uid") sel.addSelection(str(id)) req.count = 1 req.fetch_stored = True req.selections['_uid'] = sel res = self.senseiClient.doQuery(req) doc = None if res.numHits > 0: if res.hits and len(res.hits) > 0: hit = res.hits[0] doc = hit.get('srcdata') if doc: return doc else: return None