[Zope-dev] Wildcards in TextIndex query. Do they work?
Chris McDonough
chrism@digicool.com
Wed, 30 May 2001 05:16:51 -0400
Thanks for tracking this down... If you're so inclined, please put this
in the Collector (with a description of the problem, as well as a way to
reproduce it, the patch alone isn't nearly as helpful) so it doesn't get
dropped on the floor. I doubt very much that it's fixed in CVS.
- C
Erik Enge wrote:
>
> On Wed, 30 May 2001, Erik Enge wrote:
>
> > I'm going bug hunting...
>
> I'm back :)
>
> I think I found the bug. In lib/python/SearchIndex/GlobbingLexicon.py in
> the query_hook() method. It seems to say that: "if I can't find a '*' or
> a '?' in the word, then go to else-clause", where the else-clause says
> sodd off.
>
> Since it iterates over the query, 'word' is actually a list if you use
> parens in your query, and you won't find any wildcards there. I think.
>
> Add a dash of recursiveness, and it seems to be solved (for me):
>
> def erik_hook(self, q):
> "doc string"
> words = []
> for w in q:
> if ( (self.multi_wc in w) or
> (self.single_wc in w) ):
> wids = self.get(w)
> for wid in wids:
> if words:
> words.append(Or)
> words.append(wid)
> else:
> words.append(self.erik_hook(w))
> return words or ['']
>
> def query_hook(self, q):
> """expand wildcards"""
> words = []
> for w in q:
> if ( (self.multi_wc in w) or
> (self.single_wc in w) ):
> wids = self.get(w)
> for wid in wids:
> if words:
> words.append(Or)
> words.append(wid)
> else:
> words.append(self.erik_hook(w))
>
> Not really tested, but it seems to work. This might have been resolved in
> CVS, I don't know, should I post it as a bug?
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )