2013-05-07 158 views
3

我試圖用django-haystack索引Solr中的模型,但它返回以下錯誤(使用rebuild_index或update_index時):無法將文檔添加到Solr:[原因:找不到404錯誤]

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' 
    }, 
} 

我有發電機密封ed schema.xml多次重新啓動solr ..將其放置在solr/conf中不知道是什麼isuue

+0

它是否已啓動並且您可以通過訪問http://127.0.0.1:8983/solr瀏覽到solr服務器? – 2013-05-07 06:36:07

+0

是的,它啓動了 – 2013-05-07 06:37:20

+0

檢查solr日誌併發布錯誤信息,請 – 2013-05-07 06:43:44

回答

4

如指定in settings docs您需要指定您的核心URL。似乎你錯過了你的URL中的核心。您需要創建一個核心,並且url應如下所示:

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

我的舊代碼不需要指定最後一個'solr/default',但在更新了一些東西之後,我需要使用您指定的完整url。不確定哪個特定的版本升級導致它。 – TheGrimmScientist 2016-01-08 22:45:59

+0

我甚至指定了核心,然後它也沒有工作 – 2018-02-10 08:52:46

相關問題