def get_fuzzy_iter(self, cdx_iter, index_source, params):
        found = False
        for cdx in cdx_iter:
            found = True
            yield cdx

        if found:
            return

        # if fuzzy matching disabled
        if not to_bool(params.get('allowFuzzy', True)):
            return

        url = params['url']
        urlkey = to_native_str(params['key'], 'utf-8')

        res = self.get_fuzzy_match(urlkey, url, params)
        if not res:
            return

        rule, fuzzy_params = res

        new_iter, errs = index_source(fuzzy_params)

        is_custom = (rule.url_prefix != [''])

        rx_cache = {}

        for cdx in new_iter:
            if is_custom or self.match_general_fuzzy_query(
                    url, urlkey, cdx, rx_cache):
                cdx['is_fuzzy'] = '1'
                yield cdx
Exemple #2
0
 def _get_bool(self, name):
     v = self.params.get(name)
     return to_bool(v)
Exemple #3
0
 def _get_bool(self, name):
     v = self.params.get(name)
     return to_bool(v)