django - 向Solr添加文档失败: [Reason: Error 404 Not Found]

标签 django solr django-haystack

我正在尝试使用 django-haystack 在 Solr 中索引模型,但它返回以下错误(当使用重建索引或更新索引时):

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..不知道问题是什么

最佳答案

按照规定in settings docs您需要指定核心的 url。看来您错过了网址中的核心内容。您需要创建一个核心,并且 url 应如下所示:

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

关于django - 向Solr添加文档失败: [Reason: Error 404 Not Found],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16411943/

相关文章:

ruby-on-rails - 如何使用 Sunspot/Solr 在 has_many 关联中进行搜索?

django - xapian 和 django-haystack

django - 精确查找的 QuerySet 值必须使用切片限制为一个结果

Django休息框架: many to many through model write-able

python - 如何使用具有自定义属性的 django-haystack 搜索面?

mysql - 寻找以低内存成本执行全文搜索的解决方案

Django elasticsearch 传输错误找不到查询

python - 在 Django 中放置额外启动代码的正确位置?

Django新手ManyToManyField模板问题

solr - Sunspot Solr 不返回任何结果但没有错误