コード例 #1
0
    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)
コード例 #2
0
ファイル: ramindex.py プロジェクト: skrieder/microblog
    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
コード例 #3
0
    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)
コード例 #4
0
 def replace(self):
     if not self.is_active():
         return NullMatcher()
     return self
コード例 #5
0
ファイル: spans.py プロジェクト: larisharis/lovesupermarket
 def replace(self, minquality=0):
     # TODO: fix this
     if not self.is_active():
         return NullMatcher()
     return self