【发布时间】:2016-07-02 04:48:31
【问题描述】:
我目前正在生产中使用 Solr 4.2.0(在 2012 年左右设置)。我已经建立了一个新的开发环境,我升级了所有包(Django 1.8.10、PySolr 3.4.0、Haystack 2.4.1)并设置了 Solr 5.5.0
总之
我正在运行 Solr,我的核心/集合是用“basic_configs”创建的,它似乎运行良好,除了在索引过程中我收到很多类似于这些的错误:
All documents removed.
Indexing 9604 contracts
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.22] unknown field 'status']
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.70556] unknown field 'date_signed']
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.72059] unknown field 'date_signed']
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.73458] unknown field 'date_signed']
查看 id,似乎大多数文档都很好,但这些错误出现在所有表/索引中的频率足够高(不胜枚举)。
最终我关注了this promising github project guide,但不幸的是它并没有为我解决问题。
我做了什么,一步一步
- 已成功安装 Solr 5.5.0(Web 界面在
本地主机:8983),使用this guide - 使用以下命令创建了一个名为“spng”的集合:sudo su - solr -c '/opt/solr/bin/solr create -c spng -d basic_configs'
- 用来自the earlier mentioned github project guide 的 solr.xml 覆盖了我的 solr.xml (/srv/spng/src/django-haystack/haystack/templates/search_configuration/solr.xml)
- 只是为了确保我授予了 solr.xml 文件 777 权限。
我的 settings.py 有以下条目:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://localhost:8983/solr/spng',
'DEFAULT_OPERATOR': 'AND',
'INCLUDE_SPELLING': True,
},
}
- 我创建了一个 schema.xml (python manage.py build_solr_schema) 并将其放在 /var/solr/data/spng/conf/schema.xml 中
- 再次,只是为了确保我给 schema.xml 文件也赋予了 777 权限。
- 我使用 curl 命令重新加载内核:curl 'http://localhost:8983/solr/admin/cores?action=RELOAD&core=spng&wt=json&indent=true'
回复是:
{
"responseHeader":{
"status":0,
"QTime":300}}
- 我还重新启动了 uwsgi 和 solr 以确保
- 此时我尝试运行 python manage.py rebuild_index 命令
如前所述,我最终遇到以下错误:
All documents removed.
Indexing 9604 contracts
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.22] unknown field 'status']
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.70556] unknown field 'date_signed']
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.72059] unknown field 'date_signed']
Failed to add documents to Solr: Solr responded with an error (HTTP 400): [Reason: ERROR: [d
oc=accounting.contract.73458] unknown field 'date_signed']
有人知道可能出了什么问题吗?索引在我的生产服务器上正常工作,运行 4.2.0。是我错过了某个设置还是 Solr 5.5.0 导致了这些错误?
【问题讨论】:
标签: python django solr django-haystack pysolr