3

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?",
    },
])

Then I get an error:

pysolr.SolrError: Solr responded with an error (HTTP 404): [Reason: None]

After looking up I found that the URL entered must not be correct, so I changed it to my collection's URL.

solr = pysolr.Solr('http://localhost:8983/solr/#/gettingstarted/', timeout=10)

Now I get the error below:

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

There are tons of questions on the above two errors, but all the resources I found are mostly dealing with some other specific scenarios. So, my question is that how do I give pySolr the correct URL and if the second URL is correct then how to deal with the above error.

4

1 回答 1

6

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

核心直接在下/solr,所以正确的 URL 应该是http://localhost:8983/solr/gettingstarted/

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

于 2016-03-17T08:04:51.600 回答