2013-05-06 52 views
1

我想指数模型Solr中与Django的草垛,但它返回我下面的错误(使用rebuild_index或update_index时):无法将文档添加到Solr:原因:无]

Indexing 2 jobposts 
Failed to add documents to Solr: [Reason: None] 
<response><lst name="responseHeader"><int name="status">400</int><int name="QTime">358</int></lst><lst name="error"><str name="msg">ERROR: [doc=jobpost.jobpost.1] unknown field 'django_id'</str><int name="code">400</int></lst></response> 

这是search_indexes.py

from haystack import indexes 
from haystack.indexes import SearchIndex 
from jobpost.models import * 



class JobIndex(indexes.SearchIndex, indexes.Indexable): 
    text = indexes.CharField(document=True, use_template=True) 
    post_type = indexes.CharField(model_attr='post_type') 
    location = indexes.CharField(model_attr='location') 
    job_type = indexes.CharField(model_attr='job_type') 
    company_name = indexes.CharField(model_attr='company_name') 
    title = indexes.CharField(model_attr='title') 

    def get_model(self): 
     return jobpost 

    def index_queryset(self,**kwargs): 
     return self.get_model().objects.all() 
+0

看看我的答案为同一种[问题](http://stackoverflow.com/questions/15868052/cant-build-index-for-solr-haystack-unknown-field-django -id/20661704#20661704)。它可能有帮助 – NEB 2013-12-18 15:16:11

回答

2

你需要更新你的Solr引擎schema.xml,因为它写here

“你需要修改你的模式你可以摹通过运行./manage.py build_solr_schema从应用程序中安装此应用程序(一旦Haystack安装并设置)。从该命令获取输出并将其放置在apache-solr-3.5.0/example/solr/conf/schema.xml中。然后重新启动Solr。“

+0

做了很多次,但仍然出现错误 – 2013-05-06 09:54:54

+0

提供的错误告诉我们,solr找不到字段'django_id'的定义,这个字段是由'build_solr_schema'命令产生的。请检查,如果它真的出现在'apache-solr-3.5.0/example/solr/conf/schema.xml'中,并且不要忘记重新启动Solr – stalk 2013-05-06 09:59:46

+0

现在它说'无法将文档添加到Solr: [原因:错误404未找到] ' – 2013-05-06 10:05:45