编程语言
首页 > 编程语言> > python – 在Django中使用HayStack Solr进行高级搜索?

python – 在Django中使用HayStack Solr进行高级搜索?

作者:互联网

我尝试了在Haystack网站http://django-haystack.readthedocs.org/en/latest/tutorial.html上给出的基本教程,它的基本搜索工作正常.
但是它的搜索无效,因为假设我的Note模块有3个文本字段条目.

> Twitter Bootstrap设计师需要设计/编辑网站主题
>在Ubuntu上使用mod_wsgi,virtualenv的Django(python)应用程序
> Python考试将在拉贾斯坦邦举行.

当我搜索

python结果:2& 3文本字段.

python考试结果:第3个文本字段

但是当搜索python flask时它什么都没有.我想再次获得第二和第三个结果,因为有python关键字.

当搜索引导没有结果,但它应该显示第一个结果,它已在引导字启动.

当搜索pyton时没有结果,但它应该显示第2和第3个结果,因为它只有1个char从python中丢失.

当搜索bootstrap django再没有结果,但它应该显示第1和第2结果.

所以,它看起来像我缺少干草堆的一些高级设置.

如何使其更有效的搜索,以便它给出更好的结果,而不仅仅是直接匹配?

解决方法:

我已回复您的各种问题作为内联回复.

but when searched python flask it results in nothing. I want 2nd and
3rd result again, as there is python keyword.

您想要将干草堆运算符从AND更改为OR.有关更多信息,请参见http://django-haystack.readthedocs.org/en/v2.1.0/settings.html#haystack-default-operator.

when searched boot no result, but it should show 1st result, it has
boot in bootstrap word.

查看NgramField和EdgeNgramField以进行部分匹配.

when searched pyton again no result, but it should show 2nd and 3rd
result, since it only 1 char h missing from python.

看看干草堆的拼写建议:http://django-haystack.readthedocs.org/en/latest/searchqueryset_api.html#spelling-suggestion

when searched bootstrap django again no result, but it should show 1st
and 2nd result.

这是由haystack运算符配置的.

Haystack 2.0的示例配置,默认运算符设置为OR,INCLUDE_SPELLING = True

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://localhost:9001/solr/default',
        'INCLUDE_SPELLING': True,
    },
}
HAYSTACK_DEFAULT_OPERATOR = 'OR'

标签:django-haystack,python,search,django,solr
来源: https://codeday.me/bug/20190825/1720185.html