【问题标题】:Failed to add documents to Solr: [Reason: Error 404 Not Found]无法将文档添加到 Solr:[原因:找不到错误 404]
【发布时间】: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


【解决方案1】:

正如in settings docs 指定的那样,您需要指定核心的 url。好像您错过了 URL 中的核心。您需要创建一个核心,并且 url 应该如下所示:

'URL': 'http://localhost:9001/solr/default',

【讨论】:

  • 我的旧代码不需要指定最后一个solr/default,但是在更新了一些东西之后,我需要使用您指定的完整网址。不确定是哪个特定版本升级引起的。
  • 我什至指定了核心然后它也不起作用
猜你喜欢
  • 2015-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-13
  • 2018-10-21
  • 1970-01-01
  • 2016-07-02
  • 1970-01-01
相关资源
最近更新 更多