Django / Haystack

If your application is using Django, you can use the Haystack Solr client. Once you have set up your application as per their official getting started tutorial, you should modify your application’s settings.py to use these settings:

# settings.py
HAYSTACK_URL         = os.environ.get('WEBSOLR_URL', '')
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': HAYSTACK_URL,
    },
}

When you are ready to deploy to Heroku, use the following command to generate your Solr schema.xml, to be uploaded to your Websolr index:

./manage.py build_solr_schema > schema.xml

Copy the contents of the schema.xml file and open the Websolr addon dashboard:

heroku addons:open websolr

Select your index, and select the “Advanced” tab to paste in the contents of your schema.xml. Your index will take a minute or two to reconfigure itself, and then you can run the following command to reindex your data:

heroku run python myproject/manage.py rebuild_index