【发布时间】:2014-06-26 01:25:50
【问题描述】:
我目前正在使用以下 django-haystack 代码在我的网站上进行搜索:
def products_search_results(request):
q = request.GET['q']
from haystack.query import SearchQuerySet
products = SearchQuerySet().models(Product).filter(text=q)
这使用q 作为搜索中的查询参数。这也使用q 中的所有单词来匹配结果。这可能是(?)预期的默认行为。这就是我所看到的。
我有一个标题为“Red Corvette”的Product。
当然,搜索词“Red”、“Red Corvette”和“Corvette”都匹配,但搜索词“Red Corvette Convertible”或“Red Corvette T-top”将不匹配。我真的很希望那些匹配查询,特别是如果默认查询的结果不多。
我可以对我的 haystack 查询做些什么来获得这种行为吗?
【问题讨论】:
-
当我安装 Haystack 时,您需要的是默认行为。也许它已被设置为最新 Haystack 的默认设置,因为您的问题是从 2014 年开始的。
标签: python django elasticsearch django-haystack