【问题标题】:Websorl returns error " unknown field 'django_ct' " when building schema.xmlWebsorl 在构建 schema.xml 时返回错误“未知字段 'django_ct'”
【发布时间】:2019-09-25 08:57:43
【问题描述】:

我们的网站使用 Python 3.6.5 运行,并且:

  • django==1.11.20
  • django-haystack==2.8.1
  • 证书==0.0.8
  • urllib3=1.21.1
  • pysolr==3.8.1

我使用 django-haystack (python manage.py build_solr_schema > schema.xml) 生成了 schema.xml,并将其粘贴到 websolr(heroku 版本)中。

当我运行以下命令时:

heroku run python manage.py rebuild_index --app terradiem

我收到以下错误:

无法将文档添加到 Solr:Solr 响应错误 (HTTP 400):[原因:错误:[doc=naturalearth.naturalearthmerged.12001] 未知字段 'django_ct']

Traceback(最近一次调用最后一次): 文件“/app/.heroku/python/lib/python3.6/site-packages/haystack/backends/solr_backend.py”,第 72 行,更新中 self.conn.add(docs, commit=commit, boost=index.get_field_weights())

文件“/app/.heroku/python/lib/python3.6/site-packages/pysolr.py”,第 918 行,添加 覆盖=覆盖,处理程序=处理程序)

文件“/app/.heroku/python/lib/python3.6/site-packages/pysolr.py”,第500行,在_update中

return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})

文件“/app/.heroku/python/lib/python3.6/site-packages/pysolr.py”,第 412 行,在 _send_request 引发 SolrError(error_message % (resp.status_code, solr_message)) pysolr.SolrError:Solr 响应错误(HTTP 400):[原因:错误:[doc=naturalearth.naturalearthmerged.12001] 未知字段 'django_ct']

我猜它与 schema.xml 中的以下几行有关:

<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="django_ct" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/>

有什么线索吗?

【问题讨论】:

  • 我对 websolr 不熟悉,但是在更改 schema.xml 文件后,您通常需要重新加载或重新启动内核。
  • 您是否在设置中将“django.contrib.contenttypes”添加到您的 INSTALLED_APPS 中?
  • 我重新加载了核心并包含了 'django.contrib.contenttypes。错误仍然存​​在。

标签: django heroku solr django-haystack websolr


【解决方案1】:

我无法让它与 Solr 一起使用。

如果它对其他人有用,以下是我设法让 Django 和 Heroku 与 django-haystack 一起工作的方法:

我改用 Heroku Bonsai 和 ElasticSearch。

版本组合非常复杂,因为 Haystack 尚不支持 Elasticsearch 5.x、6.x 或 7.x,而多租户 Bonsai 计划仅支持 5.4.3 / 6.5.4 / 7.2.0 版本

因此,我安装了一个支持 ElasticSearch 5 的 django-haystack 分支: https://github.com/tehamalab/django-haystack-es

并在 Heroku 中创建插件如下:

heroku addons:create bonsai:staging -a terradiem --version=5.6.16

现在一切都很好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-23
    • 1970-01-01
    • 2012-03-13
    • 1970-01-01
    • 1970-01-01
    • 2020-03-12
    • 1970-01-01
    • 2019-10-09
    相关资源
    最近更新 更多