Last active
March 28, 2019 11:54
-
-
Save stvbdn/4330372 to your computer and use it in GitHub Desktop.
Django + Haystack + Solr Installation/Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Solr Install ### | |
Install pysolr and django-haystack and set up django-haystack. Setup for haystack is pretty straight forward: | |
https://django-haystack.readthedocs.org/en/v1.2.7/tutorial.html | |
Make sure you follow the haystack instructions for the correct version of haystack that you installed, | |
as some of the setting variables are different depending on the version. | |
# SSH into the server that you want to install Solr on | |
ssh 192.168.1.1 | |
# Download Solr | |
sudo curl -O http://apache.mirror.vexxhost.com/lucene/solr/3.6.1/apache-solr-3.6.1.zip | |
- Note: Or go here: http://lucene.apache.org/solr/ and download the latest version. | |
- Note 2: Make sure you dont download the "-src" version | |
# Unzip the file | |
sudo unzip apache-solr-3.6.1.zip | |
- Note: Unzip in whichever directory, I put it in the root directory. | |
# Give the new folder permissions | |
chmod 777 -R apache-solr-3.6.1 | |
# cd into the example directory | |
cd apache-solr-4.0.0/example | |
# Start the Solr Server | |
java -jar start.jar | |
# Build the schema out for solr and save it to schema.xml | |
python manage.py build_solr_schema > schema.xml | |
- Note: Do this is your django project directory | |
# Replace the solr schema in "apache-solr-3.6.1/example/solr/conf/schema.xml" with the one you made in the previous step | |
Just copy it over transmit. the schema.mxl file might not be at this exact location, it depends on your solr version. | |
# ( If Java isn't already installed ) Install Java | |
http://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7 | |
# restart the Solr Server | |
java -jar start.jar | |
# Build the Search index | |
python manage.py rebuild_index | |
-Note: Do this in your django project directory | |
# Set up Jetty | |
http://wiki.apache.org/solr/SolrJetty | |
# Set up a cron job to update the search indexes | |
0 */2 * * * cd DJANGO_PROJECT_PATH & PYTHON_PATH MANAGE_PATH update_index --age=<num_hours> > CRON_LOG_PATH 2>&1 | |
Example: This will update the index every 2 hours. | |
0 */2 * * * cd /home/lift/www/eea.org/eea & /home/lift/virtualenvs/eea/bin/python /home/lift/www/eea.org/eea/manage.py update_index --age=2 > /home/lift/www/eea.org/logs/cron.txt 2>&1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can we use solr 5.4.0 with haystack?