Failed to add documents to Solr: [Reason: Error 404 Not Found]

橙三吉。 提交于 2019-12-01 06:33:26

问题


I'm trying to index a model in Solr with django-haystack, but it returns me the following error(when using rebuild_index or update_index) :

Failed to add documents to Solr: [Reason: Error 404 Not Found]

This is 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 connection:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr',

        'SITECONF': 'jobpost.search_sites'
    },
}

I have generated schema.xml many times restarted solr..placed it in solr/conf..don't know what's the isuue


回答1:


As specified in settings docs you need to specify the url to your core. Seems like you've missed the core in your URL. You need to create a core and the url should look like this:

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


来源:https://stackoverflow.com/questions/16411943/failed-to-add-documents-to-solr-reason-error-404-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!