Django Haystack+Xapian:使用AutoQuery进行不区分大小写的搜索

2024-05-03 04:19:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用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

我使用的是django haystack中包含的SearchView和{}。在

目前,查询'Plat'得到3个结果,这是正确的,查询'Plat'没有返回任何结果,如果搜索是区分大小写的,这也是正确的。在


Tags: djangotext用户truemodeldef区分搜索引擎