Beispiel #1
0
def getSize(request,store_name):
  store = None
  try:
    store = ContentStore.objects.get(name=store_name)
  except ContentStore.DoesNotExist:
    resp = {'ok' : False,'error' : 'store: %s does not exist.' % store_name}
    return HttpResponseNotFound(json.dumps(resp))
  senseiHost = store.broker_host
  senseiPort = store.broker_port
  senseiClient = SenseiClient(senseiHost,senseiPort)
  req = SenseiRequest()
  req.count = 0
  res = senseiClient.doQuery(req)
  resp = {'store':store_name,"size":res.totalDocs}
  return HttpResponse(json.dumps(resp))
Beispiel #2
0
def getSize(request,store_name):
  store = None
  try:
    store = ContentStore.objects.get(name=store_name)
  except ContentStore.DoesNotExist:
    resp = {'ok' : False,'error' : 'store: %s does not exist.' % store_name}
    return HttpResponseNotFound(json.dumps(resp))
  senseiHost = store.broker_host
  senseiPort = store.broker_port
  senseiClient = SenseiClient(senseiHost,senseiPort)
  req = SenseiRequest()
  req.count = 0
  res = senseiClient.doQuery(req)
  resp = {'store':store_name,"size":res.totalDocs}
  return HttpResponse(json.dumps(resp))
Beispiel #3
0
  def execute_bql(stmt):
    req = SenseiRequest(stmt)
    store = my_client.store_map.get(req.index)
    if not store:
      print "Store %s does not exist!" % req.index
      return

    client = SenseiClient(store["broker_host"], store["broker_port"])
    if req.stmt_type == "select":
      res = client.doQuery(req)
      res.display(req.get_columns(), 1000)
    elif req.stmt_type == "desc":
      sysinfo = client.getSystemInfo()
      sysinfo.display()
    else:
      print "Wrong command: %s" % stmt
Beispiel #4
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
Beispiel #5
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
Beispiel #6
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
Beispiel #7
0
 def getSize(self):
   req = SenseiRequest()
   req.count = 0
   res = self.senseiClient.doQuery(req)
   return res.totalDocs
Beispiel #8
0
 def exe_sql(stmt, client):
   # test(stmt)
   req = SenseiRequest(stmt)
   res = client.doQuery(req)
   res.display(req.get_columns(), 1000)