

def do_filter(self, engine_slug, queryset, search_text):
    'Filters the given queryset according the the search logic for this backend.'
    model = queryset.model
    db_table = connection.ops.quote_name(SearchEntry._meta.db_table)
    model_db_table = connection.ops.quote_name(model._meta.db_table)
    pk = model._meta.pk
    id = connection.ops.quote_name((pk.db_column or pk.attname))
    word_query = ['\n            ({db_table}.{engine_slug} = %s)\n        ', '\n            ({db_table}.{content_type_id} = %s)\n        ']
    word_kwargs = {
        'db_table': db_table,
        'model_db_table': model_db_table,
        'engine_slug': connection.ops.quote_name('engine_slug'),
        'title': connection.ops.quote_name('title'),
        'description': connection.ops.quote_name('description'),
        'content': connection.ops.quote_name('content'),
        'content_type_id': connection.ops.quote_name('content_type_id'),
        'object_id': connection.ops.quote_name('object_id'),
        'object_id_int': connection.ops.quote_name('object_id_int'),
        'id': id,
        'iregex_operator': connection.operators['iregex'],
    }
    word_args = [engine_slug, ContentType.objects.get_for_model(model).id]
    if has_int_pk(model):
        word_query.append('\n                ({db_table}.{object_id_int} = {model_db_table}.{id})\n            ')
    else:
        word_query.append('\n                ({db_table}.{object_id} = {model_db_table}.{id})\n            ')
    for word in search_text.split():
        regex = regex_from_word(word)
        word_query.append('\n                ({db_table}.{title} {iregex_operator} OR {db_table}.{description} {iregex_operator} OR {db_table}.{content} {iregex_operator})\n            ')
        word_args.extend((regex, regex, regex))
    full_word_query = ' AND '.join(word_query).format(**word_kwargs)
    return queryset.extra(tables=(db_table,), where=(full_word_query,), params=word_args)

dataset/ETHPy150Open etianen/django-watson/src/watson/backends.py RegexSearchMixin.do_filter/original