* fix: return empty result if no valid terms given
This commit is contained in:
@@ -39,7 +39,10 @@ class InvertedIndex(object):
|
|||||||
def query(self, terms, txn = None):
|
def query(self, terms, txn = None):
|
||||||
def proc(txn):
|
def proc(txn):
|
||||||
docs = [ self.get_term(x, txn) for x in terms ]
|
docs = [ self.get_term(x, txn) for x in terms ]
|
||||||
return reduce(lambda x,y: x.intersection(y), docs)
|
if docs:
|
||||||
|
return reduce(lambda x,y: x.intersection(y), docs)
|
||||||
|
else:
|
||||||
|
return set()
|
||||||
return self.d.txn_proc(proc, txn)
|
return self.d.txn_proc(proc, txn)
|
||||||
|
|
||||||
def list_terms(self, txn= None):
|
def list_terms(self, txn= None):
|
||||||
|
|||||||
Reference in New Issue
Block a user