[英]pysolr - issue with adding to index?
編輯:“測試文檔”之后和'}'之后的逗號或否會產生相同的結果
當前嘗試在我的solr安裝上使用pysolr。 僅供參考,我的solr管理頁面啟動並加載到http:// localhost:8983 / solr /
以下是令人反感的代碼的片段(從此處簡化,總體上給出了相同的錯誤)。 請注意,這只是一個片段,我具有與上述鏈接相同的導入和周圍的代碼。
# Setup a Solr instance. The timeout is optional.
solr = pysolr.Solr('http://localhost:8983/solr/', timeout=10)
# How you'd index data.
solr.add([
{
"id": "doc_1",
"title": "A test document",
}
])
運行此程序時,我得到
$ python2 searcher.py
Traceback (most recent call last):
File "searcher.py", line 18, in <module>
"title": "A test document",
File "/usr/lib/python2.7/site-packages/pysolr.py", line 891, in add
overwrite=overwrite, handler=handler)
File "/usr/lib/python2.7/site-packages/pysolr.py", line 478, in _update
return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
File "/usr/lib/python2.7/site-packages/pysolr.py", line 393, in _send_request
raise SolrError(error_message % (resp.status_code, solr_message))
pysolr.SolrError: Solr responded with an error (HTTP 404): [Reason: Error 404 Not Found]
有什么方法可以診斷日志,還是我格式化不正確?
您應該在URL中指定核心/集合名稱
例如:
solr = pysolr.Solr('http://localhost:8983/solr/collection1', timeout=10)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.