简体   繁体   English

对 Solr Django 和 Haystack 安装感到困惑

[英]confused about Solr Django and Haystack installation

I'm following the tutorial in the Haystack for using solr in django.我正在按照 Haystack 中的教程在 django 中使用 solr。 I download haystack ad it to my installed apps, and I like to check my development to make sure my apps still working.我将 haystack ad 下载到我安装的应用程序中,我喜欢检查我的开发以确保我的应用程序仍然可以运行。 So when I go to my my localhost it says所以当我 go 到我的本地主机时,它说

A server error occurred.  Please contact the administrator.

and in my terminal it says在我的终端上它说

raise MissingDependency("The 'solr' backend requires the installation of 'pysolr'. Please refer to the documentation.")

and when I go to the pysolr documentation it seems as if it's to be used without haystack.当我 go 到 pysolr 文档时,它似乎可以在没有干草堆的情况下使用。 There is no mention pysolr in haystack docs and no mention of haystack in pysolr docs. haystack 文档中没有提到 pysolr,pysolr 文档中也没有提到 haystack。 Not only that, but pysolr gives an example that says不仅如此,pysolr 还举了一个例子

# If on Python 2.X

Im using python 3. I understand theres a learning curve but is there anything that has all the resources in one post?我正在使用 python 3。我知道有一个学习曲线,但是有没有什么可以在一篇文章中包含所有资源? Or must I just trial and error it out?还是我必须尝试并错误地解决它? and also can it be Kind of up to date?它也可以是最新的吗? 2.x to 3.5 is a big gap. 2.x 到 3.5 是一个很大的差距。 There are surprisingly no google videos or vimeo videos on this.令人惊讶的是,没有关于此的谷歌视频或 vimeo 视频。 any and all help is welcome.欢迎任何和所有帮助。 I know anything worth having or knowing isn't easy to come by but sheesh?我知道任何值得拥有或知道的东西都不容易得到,但嘘? the few sites Ive seen also have the url like this in urls.py我见过的少数网站在 urls.py 中也有这样的 url

(r'^search/', include('haystack.urls')),

but if I do it like that I get an error但如果我这样做,我会得到一个错误

 regex_pattern = pattern.regex.pattern

AttributeError: 'tuple' object has no attribute 'regex' AttributeError: 'tuple' object 没有属性 'regex'

this may seem like nothing to someone experienced, but to the untrained this can lead to a lot of confusion to the proper syntax.对于有经验的人来说,这似乎没什么,但对于未经训练的人来说,这可能会导致对正确语法的很多困惑。

Haystack uses different adapters to talk to different backend services , such as ElasticSearch or Solr. Haystack 使用不同的适配器与不同的后端服务 (例如ElasticSearch或Solr)进行通信。

The Solr adapter uses pysolr: Solr适配器使用pysolr:

You'll also need a Solr binding, pysolr. 您还需要一个Solr绑定pysolr。 The official pysolr package, distributed via PyPI, is the best version to use (2.1.0+). 通过PyPI分发的官方pysolr软件包是使用的最佳版本(2.1.0+)。 Place pysolr.py somewhere on your PYTHONPATH. 将pysolr.py放在PYTHONPATH上的某个位置。

You shouldn't have to do anything with pysolr yourself, as that is only used inside the haystack Solr adapter. 您不必自己对pysolr进行任何操作,因为它仅在haystack Solr适配器内部使用。 Be sure to follow the tutorial for setting up the schema and getting the indexing running. 确保遵循该教程来设置架构并运行索引。

just pip install pysolr and move about your day.只需 pip 安装 pysolr 并开始您的一天。

Personally, I used(in my virtual env):就个人而言,我使用(在我的虚拟环境中):

python3 -m pip install pysolr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM