Search code examples
pythondjangosolrread-the-docs

Setting Up Apache Solr on Local Instance of readthedocs.org


Link to Instructions

I am following the instructions at http://read-the-docs.readthedocs.org/en/latest/install.html#solr-search-setup

Question

Currently, I am able to set up a local instance of readthedocs.org; however, I cannot set up search correctly on it as I can't seem to generate the necessary schema.xml file by running the following command. The context of which is in the link above.

./manage.py build_solr_schema > $SOLR_PATH/solr/conf/schema.xml

Instead of successfully generating a schema.xml, I am presented with this error.

Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/home/***/ford-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/***/ford-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/***/ford-env/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/***/ford-env/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/***/ford-env/local/lib/python2.7/site-packages/haystack/management/commands/build_solr_schema.py", line 26, in handle
    schema_xml = self.build_template(using=using)
  File "/home/***/ford-env/local/lib/python2.7/site-packages/haystack/management/commands/build_solr_schema.py", line 52, in build_template
    c = self.build_context(using=using)
  File "/home/***/ford-env/local/lib/python2.7/site-packages/haystack/management/commands/build_solr_schema.py", line 38, in build_context
    raise ImproperlyConfigured("'%s' isn't configured as a SolrEngine)." % backend.connection_alias)

I'm guessing there is an extra step involving for configuring solr with django before generating xml. Similar errors suggest editing a settings.py file, but I cannot seem to find one within the project directory. Due to my lack of familiarity with django, I don't know how to continue from here.


Solution

  • you have to update the settings files in readthedocs.org/readthedocs/settings/*.py and update the HAYSTACK_CONNECTIONS dict with (if you're using solr):

    HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr',
        }
    }
    

    check init.py, base.py, sqlite.py. Then it worked perfectly.