def matcher(self, searcher, context=None): from whoosh.query import Or fieldname = self.field() constantscore = self.constantscore reader = searcher.reader() qs = [Term(fieldname, word) for word in self._btexts(reader)] if not qs: return matching.NullMatcher() if len(qs) == 1: # If there's only one term, just use it m = qs[0].matcher(searcher, context) else: if constantscore: # To tell the sub-query that score doesn't matter, set weighting # to None if context: context = context.set(weighting=None) else: from whoosh.searching import SearchContext context = SearchContext(weighting=None) # Or the terms together m = Or(qs, boost=self.boost).matcher(searcher, context) return m
def matcher(self, searcher, context=None): from whoosh.searching import SearchContext context = context or SearchContext() m = self.child.matcher(searcher, context) if context.needs_current or isinstance( m, cylleneus.engine.matching.mcore.NullMatcherClass): return m else: ids = array("I", m.all_ids()) return cylleneus.engine.matching.mcore.ListMatcher( ids, all_weights=self.score, term=m.term())