5

我使用 Django 和 Haystack 作为搜索引擎和后端 Xapian。如何实现所有搜索都不区分大小写?对于用户来说,如果搜索引擎忽略大小写并只返回给定搜索查询的所有值,会容易得多。

我的搜索索引目前看起来像这样(简化):

def ArticleIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.EdgeNgramField(document=True, use_template=True)
    name = indexes.CharField(model_attr='title')

    def get_model(self):
        return Article

我正在使用SearchViewSearchForm包含在 django-haystack 中。

目前,对“Plat”的查询给出 3 个结果,这是正确的,对“plat”的查询不返回任何结果,如果搜索区分大小写,这也是正确的。

4

0 回答 0