【发布时间】:2016-12-02 00:21:22
【问题描述】:
我使用 Wagtail serach:
query = self.request.query_params
questions = models.Questions.objects.filter(
answer__isnull=False,
owner__isnull=False).exclude(answer__exact='')
s = get_search_backend()
results = s.search(query[u'question'], questions)
这就是我为我的Questions 模型设置索引的方式:
search_fields = [
index.SearchField('question', partial_match=True, boost=2),
index.FilterField('answer'),
index.FilterField('owner_id')
]
但它区分大小写。所以查询how 和How 会给出不同的结果。
我需要让我的搜索行为这样:
当我输入how 或How 时,它应该返回
how to...
How to...
The way how...
THE WAY HoW...
换句话说,它应该在所有可能的情况下找到所有提及how。
如何让它发挥作用?
P.S.:我使用的是默认后端,如果需要,我可以随意更改它。
【问题讨论】:
-
您能分享一下您是如何为您的
Questions模型设置索引的吗?
标签: python django search elasticsearch wagtail