1

My solr service works without HTTP authentication, but my webhost provides it and I'd like to take advantage of it.

I've been given a username and password to access my solr service by dotcloud in the form of a url:

'http://dotcloud:XXXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/'

When I point my browser to this address, it works just fine.

In my settings.py file I have the following line:

    HAYSTACK_SOLR_URL = 'http://dotcloud:XXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/' 

but when I run ./manage.py build_solr_schema, I get the following error:

ValueError: invalid literal for int() with base 10: 'XXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com'

I don't have any problem building a schema if I remove the URL, but then I am unable to build an index ("Error 401: UNAUTHORIZED") which, of course, makes sense.

I can't find anything in the haystack docs that talks about authentication. This seems like something that would be solved by an extra couple of lines in settings.py like:

    HAYSTACK_SOLR_USER = 'dotcloud'
    HAYSTACK_SOLR_PSSWD = 'XXXXXXXXXXXXXXXXXXX'

but, no dice. A complete list of the Haystack settings reveals nothing along those lines: http://docs.haystacksearch.org/dev/settings.html .

Any ideas??

Thanks.

Matt Parrilla
  • 3,171
  • 6
  • 35
  • 54

1 Answers1

2

I ran into the same issue on dotcloud. The error actually isn't in Haystack -- it's in pysolr. Pysolr assumes that if there's a colon in the url, everything after it must be a port number.

One short term fix would be to use the following config on your dotcloud solr service to disable authentication:

config: solr_authentication: false

I would only do this in a dev environment and if you have data up there that isn't sensitive (since anybody could get to that url). The ultimate solution is to patch pysolr.

Borys
  • 511
  • 3
  • 7
  • How do I "patch pysolr"? I don't even really know what that means :-/ – Matt Parrilla Sep 27 '11 at 16:55
  • 1
    The pysolr project is hosted here: https://github.com/toastdriven/pysolr/ . You could either submit a feature/bug request through github or you could download the source, modify the lines dealing with connecting to solr, and replace the version in your deployment. Being able to handle solr urls with usernames and passwords would be very useful, so I would recommend submitting the feature request. – Borys Oct 02 '11 at 22:12
  • Thanks @Borys. I put in a feature request as I'm too much of a newb to know where to begin with the source! Will post back here if anything becomes of it. – Matt Parrilla Oct 05 '11 at 02:39