Next Tutorial
Drupal 7 Tutorial Part 16: Drupal 7 Reports & Logs Explained
How to integrate Apache Solr with Drupal 6 in windows or linux
Hi Everyone,
I want to share my experience of integrating Apache Solr (Full text search and powerful than drupal core search) with Drupal 6.
Step 1: Download Apache Solr module from here http://drupal.org/project/apachesolr, and place it in your drupal contributed modules folder.
Step 2: Before enabling the module, we need to do some additional configurations. Download the apachesolr php client library from here http://code.google.com/p/solr-php-client/downloads/list . After extracting the files, place solrphpclient folder into apachesolr module folder.
Step 3: Now enable Apache Solr Framework and Apache Solr Search modules from admin/build/moules section.
Step4: Now download Apache Solr from here. http://apache.osuosl.org//lucene/solr/1.4.1/apache-solr-1.4.1.zip and extract the contents.
Step 5: Unpack the tar ball or zip file downloaded in step 3 outsite your drupal installation and outside web root.
Step 6: Goto /apachesolr1.4.0/example/solr/conf and copy schema and solrconfig files to the same directory and rename them as schema.bak and solrconfig.bak
Step 7: Copy schema and solrconfig files from your drupal installation apachesolr module to above location and replace wih existing files.
Step 8: Now open your command prompt and browse to apachesolr1.4.0/example directory.
Step 9: Type belo command to start apachesolr service
>> java -jar start.jar
Step 10: Test your solr server admin innterface by visiting http://localhost:8983/solr/admin/ . If you can able to see admin page then your solr is running and ready to use with drupal.
Step 11: Its time to configure drupal search with apache solr. Please goto admin/settings/apachesolr/index and run cron to index the content using apache solr search engine.
Step 12: Now goto admin/settings/apachesolr click on advanced configuration and make apache solr as default search. Now go to admin/settings/apachesolr/enabled-filters and enable the sorting filtrers.
Step 13: Now goto blocks and enable the necessary apache solr related blocks.
Step 14: To enable facets please go to admin/settings/apachesolr/enabled-filters and enable filters. Now go to blocks and enable the facets filtering blocks where ever you want !!
Thats it...... Improved search performance is infront of your eyes. You can sort the content using the sort block. Amazing user experince and amazing search speed. I love it!!
Cheers,
Anil Sagar

12 comments
How can I keep it running on windows?
Hello, thanks for the article! I see the comment below about keeping it running, but that's for Linux. Any idea how to keep it running on Windows?
Good article
This is a great article !!! Helped me to integrate the Apache solr ... Thanks !!!
Solr Facets Question
I did everything as you have mentioned. My drupal is able to index data to solr and retrive search results. I have below issues
1. My facets are not showing up. I have panels, i added facets to panels. No luck with this.
2. I somehow tweaks my code to filter data by content type by adjusting the request url. But when i pass "solrsort=changed desc" in request url, data is not getting sorted.
Any suggestions ?
Thanks
Follow below steps to keep solr running
Step 1: First, find out where java is located on your machine. The command below will tell you where it is:
$ which java
Step 2: Then, stick the following code into a shell script, replacing the java path below (/usr/bin) with the path you got from the above command.<code>
#!/bin/bash
cd /usr/java/apache-solr-1.4.0/example
/usr/bin/java -jar start.jar
</code>
You can save this script in some location (e.g., $HOME) as start.sh.
Step 3: Give it world execute permission (to simplify) by running the following command:
$ chmod og+x start.sh
Step 4: Now, test the script and ensure that it works correctly from the command line.
$ ./start.sh
Step 5: Type below command
$ crontab -e
This will bring up an editor. Add the following line to it:
@reboot /home/somedir/start.sh
If your Linux system supports it (which it usually does), this will ensure that your script is run upon startup.
This should solve your problem.
Keep solr running
Thank you for your post it was very helpful. If you could please tell me how I keep solr running that would be great help. I get solr running and it works well. But after a few hours I notice that it stops and I need to start solr again using the java -jar start.jar command. I have cron running every 20 minutes.
Thank u very much.its so
Thank u very much.its so helpful article .its helped me a lot
I need help
I need help in installation of appache solr
when i clicked on this link
http://apache.mirrors.hoobly.com/lucene/solr/1.4.0/apache-solr-1.4.0.zip
I got following error
Not Found
Hi
I updated the link. Now you can able to download.
Cheers,
Anil Sagar
Excellent
Excellent information
Thank you !
Great , thank you !
Need more info.
Hi Sagar, thanks for your kind info. but i have some queries. i have installed the apache solr in localhost. it works fine. but how to install it in the server side ? How to Keep the Apache Solr Running? (Ie...>> java -jar start.jar) Where to place the "apache-solr-1.4.0" folder ..??
It will be very helpful to me if you give the info.
little query..
U are running start.jar..
Does it need to keep running for solr to work day n night...
Or is dere any other way out..