def hypersearch(self,query,user): """ search the hyperestraier index via the p2p client """ hyper = h(url=os.environ['RCACHE_HYPER_URL']) try: res = hyper.search(query,user.id) lst,dct = hyper.id_lst() print "entries found: %s" % str(len(lst)) #print dct if len(lst) > 0: in_str = "id IN (%s)" % ",".join(lst) entries = Entry.objects.filter(user=user).extra(where=[in_str,]) qs = [] for entry in entries: id = str(entry.id) the_attrs = dct[id] #print the_attrs entry.set_hyper_attrs(the_attrs) qs.append(entry) else: return [] return qs except Exception, e: raise #re-raise the SearchError
def load(): """ load the rcache database into a newly-minted hyperestraier node """ hc = h(url='http://127.0.0.1:1972/node/rcache') docs = Entry.objects.all() for doc in docs: try: hc.doc_add(doc) print "loaded entry # %s" % doc.id except Exception, e: print "Could not load entry into HyperEstraier" print e