def postings(self, fieldname, text, scorer=None): try: postings = self.invindex[fieldname][text] except KeyError: raise TermNotFound((fieldname, text)) excludeset = self.deleted format = self.schema[fieldname].format if excludeset: postings = [x for x in postings if x[0] not in excludeset] if not postings: return NullMatcher() ids, weights, values = zip(*postings) return ListMatcher(ids, weights, values, format=format)
def postings(self, fieldname, text, scorer=None): self._test_field(fieldname) try: terminfo = self.term_info(fieldname, text) except KeyError: raise TermNotFound((fieldname, text)) format = self.schema[fieldname].format postings = self.invindex[fieldname][text] excludeset = self.deleted if excludeset: postings = [x for x in postings if x[0] not in excludeset] if not postings: return NullMatcher() ids, weights, values = zip_(*postings) lm = ListMatcher(ids, weights, values, format=format, scorer=scorer, term=(fieldname, text), terminfo=terminfo) return lm
def matcher(self, searcher, context=None): fieldname = self.fieldname condition = self.condition if callable(condition): comp = condition else: def comp(v): # Made this a function instead of a lambda so I could put # debug prints here if necessary ;) return v == condition reader = searcher.reader() if not reader.has_column(fieldname): return NullMatcher() creader = reader.column_reader(fieldname) return ColumnMatcher(creader, comp)
def replace(self): if not self.is_active(): return NullMatcher() return self
def replace(self, minquality=0): # TODO: fix this if not self.is_active(): return NullMatcher() return self