Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
  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