pysolr: HTTP method POST not supported by this url

Puk*_*kki 2 solr pysolr python-3.x

I am new to Solr and PySolr and I am trying to create a web-app. I am planning to use PySolr but when I try to run an example script I get errors. Below are the details:

import pysolr

# 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",
    },
    {
        "id": "doc_2",
        "title": "The Banana: Tasty or Dangerous?",
    },
])
Run Code Online (Sandbox Code Playgroud)

Then I get an error:

pysolr.SolrError: Solr responded with an error (HTTP 404): [Reason: None]
Run Code Online (Sandbox Code Playgroud)

查了一下,发现输入的网址肯定不对,所以我把它改成了我收藏的网址。

solr = pysolr.Solr('http://localhost:8983/solr/#/gettingstarted/', timeout=10)
Run Code Online (Sandbox Code Playgroud)

现在我收到以下错误:

pysolr.SolrError: Solr responded with an error (HTTP 405): [Reason: None] 
HTTP method POST is not supported by this URL
Run Code Online (Sandbox Code Playgroud)

关于上述两个错误有很多问题,但我找到的所有资源主要是处理其他一些特定场景。所以,我的问题是如何给 pySolr 正确的 URL,如果第二个 URL 正确,那么如何处理上述错误。

Mat*_*ndh 5

#URL的一部分永远不会发送到服务器 - 它是只有客户端本身应该访问的本地锚点。您使用的 URL 是管理界面中的 javascript 用于设置要显示的当前页面的管理界面 URL。

核心在 下直接可用/solr,因此正确的 URL 应该是http://localhost:8983/solr/gettingstarted/.

进行查询时,您还可以在管理界面内的查询界面中看到这一点(URL 显示在顶部 - 您对没有选择处理程序的部分感兴趣)。