[英]Can't build index for solr/haystack: unknown field 'django_id'
我正在尝试跟随干草堆教程。 运行manage.py rebuild index时遇到错误
我收到以下错误:
WARNING: This will irreparably remove EVERYTHING from your search index.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
/Users/heri0n/python_env/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2013-04-07 16:14:15.481145) while time zone support is active.
RuntimeWarning)
Indexing 1 notes.
Failed to add documents to Solr: [Reason: None]
<response><lst name="responseHeader"><int name="status">400</int><int name="QTime">6</int></lst><lst name="error"><str name="msg">ERROR: [doc=haystacktester.note.3] unknown field 'django_id'</str><int name="code">400</int></lst></response>
我确实运行了manage.py build_solr_schema>〜/ solr-4.2.1 / example / solr / conf / schema.xml
我不得不手动创建conf目录,因为它不存在。 我注意到教程使用Solr 3而我正在使用4。conf dir的位置是否也改变了?
问题是Solr(haystack文档使用v3.5.0,这里你可能使用最新的)没有找到配置文件。 这3个步骤对我有用
将架构放在solr-xyz / example / solr / collection1 / conf / schema.xml中
在架构中将stopwords_en.txt更改为lang / stopwords_en.txt
将version字段(如下所述)添加到fields部分中的架构中
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
有关更多信息,请查看GitHub中的相同讨论
这更像是一个评论,但由于我缺乏积分,我无法发表评论......
有没有人找到解决这个问题? 我有完全相同的问题。 该字段在schema.xml
中创建,如下所示:
<field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/>
我重新启动了Solr(多次),我100%肯定我的schema.xml代码是正确的。 到底发生了什么事?
编辑:我切换到Elasticsearch并没有问题。 但是,我相信其他人会在这个问题上找到帮助。
我不得不克隆干草堆源代码并做一些黑客攻击如下:
在/haystack/management/commands/build_solr_schema.py中,我在build_context()
函数中注释了DJANGO_ID
。 然后在/haystack/templates/search_configuration/solr.xml
,我用"django_id"
替换了{{ DJANGO_ID }}
,一切正常。
我认为生成schema.xml
时{{DJANGO_ID}}
没有被"django_id"
替换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.