pysolr: HTTP method POST not supported by this url

Viewed 1756

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.

1 Answers
Related