【发布时间】:2013-05-07 05:41:40
【问题描述】:
我正在尝试使用 django-haystack 为 Solr 中的模型建立索引,但它返回了以下错误(使用rebuild_index 或 update_index 时):
Failed to add documents to Solr: [Reason: Error 404 Not Found]
这是 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()
干草堆连接:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr',
'SITECONF': 'jobpost.search_sites'
},
}
我生成了schema.xml很多次重启solr..放在solr/conf..不知道是什么问题
【问题讨论】:
-
是否启动,可以访问127.0.0.1:8983/solr浏览到solr服务器?
-
请检查 solr 日志并发布错误是什么
-
org.apache.solr.common.SolrException: 错误: [doc=jobpost.jobpost.1] 未知字段 'django_id'
-
您的 schema.xml 错误。它缺少字段
django_id。你能发布你的schema.xml吗?您可能已经生成了架构,但没有将其复制到您的 Solr 安装中。 -
使用另一个版本的 solr 解决了它
标签: django solr django-haystack