If specific meta search finds nothing, make unspecfic meta search.

This commit is contained in:
Michael Rodin 2022-12-02 16:42:40 +01:00
parent 527f006e6b
commit 291fffe057

View file

@ -244,9 +244,10 @@ class metatable(database):
self.collist=["NAME","ALIAS"] self.collist=["NAME","ALIAS"]
super().__init__(filepath) super().__init__(filepath)
def add_index(self,val,alias): def add_index(self,val,alias,randhex=None):
randhex=get_randhex() if not randhex:
val=re.sub('[ ?!/\\:!*"<>|]', '', val) randhex=get_randhex()
val=re.sub('[ ,?!/\\:!*"<>|]', '', val)
super().add_index([val[:8] + "-" + randhex,alias]) super().add_index([val[:8] + "-" + randhex,alias])
def check_index(self,typ): def check_index(self,typ):
@ -282,6 +283,12 @@ class metatable(database):
def search_index(self,args,quiet=True): def search_index(self,args,quiet=True):
selection=[] selection=[]
selection=self.sql_compare_list("*", [args], selection,True) selection=self.sql_compare_list("*", [args], selection,True)
if selection[0] == ".":
slist=args.split(" ")
selection=self.sql_compare_list("*", slist, [],False)
if len(selection) > 1:
print("Please enter a more specific search query!")
return "."
selection=self.select_index(selection,quiet) selection=self.select_index(selection,quiet)
return selection return selection