@@ -397,16 +397,29 @@ def make_catwhere(self):
397397 #deepcopy lets us get a real copy of the dictionary
398398 #that can be changed without affecting the old one.
399399 mydict = copy .deepcopy (self .outside_dictionary )
400- #This may make it take longer than it should; we might want the list to
401- #just be every bookid with the given word rather than filtering by the limits.
402- #It's not obvious to me which will be faster.
400+ # This may make it take longer than it should; we might want the list to
401+ # just be every bookid with the given word rather than
402+ # filtering by the limits as well.
403+ # It's not obvious to me which will be faster.
403404 mydict ['search_limits' ] = copy .deepcopy (self .limits )
404- mydict ['search_limits' ]['word' ] = copy .deepcopy (mydict ['search_limits' ]['hasword' ])
405- del mydict ['search_limits' ]['hasword' ]
405+ if isinstance (mydict ['search_limits' ]['hasword' ],basestring ):
406+ #Make sure it's an array
407+ mydict ['search_limits' ]['hasword' ] = [mydict ['search_limits' ]['hasword' ]]
408+ """
409+ #Ideally, this would shuffle into an order ensuring that the rarest words were nested deepest.
410+ #That would speed up query execution by ensuring there wasn't some massive search for 'the' being
411+ #done at the end.
412+
413+ Instead, it just pops off the last element and sets up a recursive nested join. for every element in the
414+ array.
415+ """
416+ mydict ['search_limits' ]['word' ] = [mydict ['search_limits' ]['hasword' ].pop ()]
417+ if len (mydict ['search_limits' ]['hasword' ])== 0 :
418+ del mydict ['search_limits' ]['hasword' ]
406419 tempquery = userquery (mydict ,databaseScheme = self .databaseScheme )
407420 listofBookids = tempquery .bookid_query ()
408- from uuid import uuid4
409- random_string = re .sub ("-" ,"" ,str (uuid4 ()))
421+ # from uuid import uuid4
422+ # random_string = re.sub("-","",str(uuid4()))
410423 #I don't want collisions--a uuid is overkill, but works.
411424 self .catwhere = self .catwhere + " AND fastcat.bookid IN (%s)" % (listofBookids )
412425
0 commit comments