Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create a core #318

Open
1 of 3 tasks
Dimfred opened this issue May 8, 2020 · 2 comments
Open
1 of 3 tasks

Unable to create a core #318

Dimfred opened this issue May 8, 2020 · 2 comments

Comments

@Dimfred
Copy link

Dimfred commented May 8, 2020

I have

  • Tested with the latest release
  • Tested with the current master branch
  • Searched for similar existing issues

Expected behaviour

pysolr creates a new core

Actual behaviour

pysolr does not create a core

Steps to reproduce the behaviour

  1. admin = pysolr.SolrCoreAdmin("http://localhost:8983/solr/admin/cores"
  2. admin.create("corename", "<SOLR_ROOT>/server/solr/configsets/_default/conf")

Configuration

  • Operating system version: Ubuntu 20.04
  • Search engine version: 8.5.1
  • Python version: 3.7.3
  • pysolr version: 3.9.0

Could fix it with

replaced: https://github.com/django-haystack/pysolr/blob/master/pysolr.py#L1307

resp = requests.get(url, data=safe_url_encode(params), headers=headers)
with
resp = requests.get(url, data=params, headers=headers)

@cpburnz
Copy link
Contributor

cpburnz commented Aug 11, 2020

I'm experiencing this same issue on:

  • OS: Ubuntu 18.04
  • Solr: 8.6.0
  • Python: 3.6.9
  • Pysolr: 3.9.0

Did the requests library change how it handles its data argument? params is a dict in that method while safe_urlencode() serializes it to a url-encoded string.

@cpburnz
Copy link
Contributor

cpburnz commented Aug 12, 2020

Here's an example without modifying SolrCoreAdmin:

import pysolr
admin = pysolr.SolrCoreAdmin('http://localhost:8983/solr/admin/cores')
resp = admin.create('mytest')
print(resp)

This will print:

{
  "responseHeader":{
    "status":0,
    "QTime":0},
  "initFailures":{},
  "status":{}}

And Solr will log:

2020-08-12 15:02:56.786 INFO  (qtp491273700-19) [   ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/cores params={} status=0 QTime=0

Solr did not attempt to create the mytest core. It does not appear to be passing the expected parameters in the request.


Now if I modify SolrCoreAdmin._get_url() to remove the call to safe_urlencode(), and run the exact same code, it will print:

{
  "responseHeader":{
    "status":400,
    "QTime":6},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.core.SolrResourceNotFoundException"],
    "msg":"Error CREATEing SolrCore 'mytest': Unable to create core [mytest] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/var/solr/data/cores/mytest'",
    "code":400}}

And Solr will log:

2020-08-12 15:03:25.188 INFO  (qtp491273700-18) [   x:mytest] o.a.s.h.a.CoreAdminOperation core create command schema=schema.xml&name=mytest&action=CREATE&config=solrconfig.xml&instanceDir=mytest
2020-08-12 15:03:25.193 ERROR (qtp491273700-18) [   ] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: Error CREATEing SolrCore 'mytest': Unable to create core [mytest] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/var/solr/data/cores/mytest'
        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1312)
        ...

2020-08-12 15:03:25.193 INFO  (qtp491273700-18) [   ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/cores params={schema=schema.xml&name=mytest&action=CREATE&config=solrconfig.xml&instanceDir=mytest} status=400 QTime=6

This error is the expected behavior. Solr is now attempting to create the mytest core but I never created solrconfig.xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants