Failed to add documents to Solr: Solr responded with an error (HTTP 400) (django + haystack + solr)
Failed to add documents to Solr: Solr responded with an error (HTTP 400) (django + haystack + solr)
我目前在生产环境中使用 Solr 4.2.0(大约在 2012 年设置)。我已经设置了一个新的开发环境,我升级了所有包(Django 1.8.10、PySolr 3.4.0、Haystack 2.4.1)并设置了 Solr 5.5.0
简而言之
我有 Solr 运行ning,我的 core/collection 使用 '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,似乎大多数文档都很好,但这些错误出现的频率足够高(列表还在继续)tables/indexes。
最后我跟着this promising github project guide,可惜没有解决我的问题
我一步一步做的
- 已成功安装 Solr 5.5.0(Web 界面工作于
localhost: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']
有谁知道哪里出了问题?索引在我的生产服务器 运行ning 4.2.0 上没有错误。是我错过了设置还是 Solr 5.5.0 导致了这些错误?
检查
处的模式文件
http://localhost:8983/solr/#/spng/files?file=schema.xml
并与来自 build_solr_schema 的模式进行比较,以确保 solr 使用正确的模式
特别感谢 elyograg 在 Solr 的 IRC 频道(#solr on freenode)上帮助我。
elyograg: if you're using the stock solrconfig.xml from basic_configs, then your schema is located in a file named "managed-schema" -- ALL example configs are using the managed schema by default as of 5.5.
elyograg: put it (schema.xml contents) into managed-schema. You could potentially change the solrconfig.xml, but life will be easier for people trying to help you if you keep the defaults.
换句话说,从 5.5 版开始,当使用 basic_configs 创建集合时,模式文件被称为 'managed-schema'(在我的例子中位于 /var/solr/data//conf/managed-schema)
更新文件并重新加载核心后,索引完成且没有错误。
在以后的版本中要小心,因为 elyograg 还注意到:
elyograg: It might also be a good idea to add the .xml extension. I don't think the lack of an extension is going to be much of a deterrent to hand-editing.
所以以后可能会叫managed-schema.xml
Solr 索引更新包括 4 个步骤:
在search_index.py
中添加有效字段
通过 运行 生成架构:
python manage.py build_solr_schema > schema.xml
通过以下方式更新您的 django:
python manage.py update_index
重启服务器。
如果上述所有步骤都完成且没有任何错误,那么您的字段已成功更新
我目前在生产环境中使用 Solr 4.2.0(大约在 2012 年设置)。我已经设置了一个新的开发环境,我升级了所有包(Django 1.8.10、PySolr 3.4.0、Haystack 2.4.1)并设置了 Solr 5.5.0
简而言之
我有 Solr 运行ning,我的 core/collection 使用 '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,似乎大多数文档都很好,但这些错误出现的频率足够高(列表还在继续)tables/indexes。
最后我跟着this promising github project guide,可惜没有解决我的问题
我一步一步做的
- 已成功安装 Solr 5.5.0(Web 界面工作于
localhost: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']
有谁知道哪里出了问题?索引在我的生产服务器 运行ning 4.2.0 上没有错误。是我错过了设置还是 Solr 5.5.0 导致了这些错误?
检查
处的模式文件http://localhost:8983/solr/#/spng/files?file=schema.xml
并与来自 build_solr_schema 的模式进行比较,以确保 solr 使用正确的模式
特别感谢 elyograg 在 Solr 的 IRC 频道(#solr on freenode)上帮助我。
elyograg: if you're using the stock solrconfig.xml from basic_configs, then your schema is located in a file named "managed-schema" -- ALL example configs are using the managed schema by default as of 5.5.
elyograg: put it (schema.xml contents) into managed-schema. You could potentially change the solrconfig.xml, but life will be easier for people trying to help you if you keep the defaults.
换句话说,从 5.5 版开始,当使用 basic_configs 创建集合时,模式文件被称为 'managed-schema'(在我的例子中位于 /var/solr/data//conf/managed-schema)
更新文件并重新加载核心后,索引完成且没有错误。
在以后的版本中要小心,因为 elyograg 还注意到:
elyograg: It might also be a good idea to add the .xml extension. I don't think the lack of an extension is going to be much of a deterrent to hand-editing.
所以以后可能会叫managed-schema.xml
Solr 索引更新包括 4 个步骤:
在search_index.py
中添加有效字段
通过 运行 生成架构:
python manage.py build_solr_schema > schema.xml
通过以下方式更新您的 django:
python manage.py update_index
重启服务器。
如果上述所有步骤都完成且没有任何错误,那么您的字段已成功更新