0

我是 Apache Solr 的新手。在 python 中使用pysolr包添加文档时出现错误。

我试过以下:

from __future__ import print_function
import pysolr
solr = pysolr.Solr('http://localhost:8983', timeout=10)

solr.add([  
    {
        "id": "doc_1",
        "title": "A very small test document about elmo",
    }
])

我收到以下错误:

Traceback (most recent call last):
  File "ex1.py", line 16, in <module>
    { "id": "child_doc_2", "title": "seed"},
  File "/home/system/anaconda3/lib/python3.6/site-packages/pysolr.py", line 918, in add
    overwrite=overwrite, handler=handler)
  File "/home/system/anaconda3/lib/python3.6/site-packages/pysolr.py", line 500, in _update
    return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
  File "/home/system/anaconda3/lib/python3.6/site-packages/pysolr.py", line 412, 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]
4

1 回答 1

0

您的核心或集合的名称应该是 URL 的一部分,以及/solr路径前缀:

solr = pysolr.Solr('http://localhost:8983/solr/<collectionname>', timeout=10)
于 2019-01-17T08:39:50.717 回答