You are here

README.txt in Apache Solr Search 5

Apache Solr Search Integration 5.x-1.0

REAMDE Contents:
   Introduction
   Prerequisite Installations
     Sun Java 5 + Runtime Environment
     Apache Solr 1.3.x     
       Simple install option: Standalone Solr run with a java command 
       Advanced/server install option: TomCat Solr Installation run as a service
   Drupal Module Installation and Configuration
   Enable Facet blocks
   (Optional) Disable Core Search functionality with coresearches
   (Optional) Enable Node Access Support
   (Optional, Advanced) Enable Attachment Support
   Re-Index your site and run cron.php to build the index
   Sharing one Solr instance shared between many Drupal sites
   Troubleshooting
   Developer Information


Introduction
------------

This module integrates Drupal with the Apache Solr search platform. In Drupal, Solr search can be used as a replacement for core content search and boasts both extra features and better performance.  Among the extra features are the ability to have faceted search on facets ranging from content author to taxonomy to arbitrary CCK fields, and the abillity to index and "search inside" Acrobat (.pdf), Word 97-2004 (.doc), Word 2007+ (.docx), and Plain Text (.txt) attachments.

For more introductory information on Solr, visit its wikipedia entry and home page:
  http://lucene.apache.org/solr/
  http://en.wikipedia.org/wiki/Apache_Solr  

This module comes with a schema.xml file which should be used in your Solr installation.  Follow the installation steps below carefully, as the module will not just work out of the box with a default Solr configuration.

This module depends on the search framework in core.  By default, you get results from the core search functionality for content and uesrs, as well as Solr results.  If you you do not want the core search capabilities and only want Solr results returned, you need to install the Core Searches module in tandem with this module.  See the sectoin "(Optional) Disable Core Search functionality with coresearches", below.

In order to successfully set this all up on a production site, you probably need administrator access to your server, or at least cooperation/help from your system's administrator to get TomCat and Solr configured properly.


Prerequisite Installations
--------------------------

Prerequisite: Sun Java 5 + Runtime Environment  
Ideally you should run the official Sun Java JRE and not
one of the various open source alternatives.    

On Ubuntu Linux, make sure "multiverse" is enabled in System->Administration->Sofwtare Sources, then install the "sun-java6-jre" or "sun-java6-jdk" packages.  After installation use the command: "sudo update-java-alternatives -s java-6-sun" to set the Sun JRE as default.  Finally, use "java -version" to make sure you are running the official Java(TM) from Sun.

On Debian Linux, you need to enable "non-free" in your /etc/apt/sources.list and then install the sun-java5-jre package.   After installation use "sudo /usr/sbin/alternatives --config java" to set the Sun JRE as the default. 

For RedHat/Fedora Core/CentOS, install the java-1.6.0-sun package, or see http://wiki.centos.org/HowTos/JavaOnCentOS for instructions to create it if it is not available.  After installation use "sudo /usr/sbin/alternatives --config java" to set the Sun JRE as the default.

for Windows, download the correct JRE and install it for your version of windows and install it.

Once Java is correctly installed, the command "java -version" should show the Sun Java(TM) Header, e.g.

  $ java -version
  java version "1.6.0_16"
  Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
  Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)


Prerequisite: Apache Solr 1.3.x:

Download the latest Solr 1.3.x release from a mirror site:
http://www.apache.org/dyn/closer.cgi/lucene/solr/

At 1.0 release time, the latest version was apache-solr-1.3.0.tgz.

Unpack the apache_solr-1.3.0.tgz somewhere not visible to the web (not in your apache docroot and not inside of your drupal directory). 

$ tar xzvf apache_solr-1.3.0.tgz

The Solr download comes with an example instance (named "example") that you can use as-is for testing, development, and even for smaller production sites. This instance is found in the apache-solr-1.3.0/example folder.  These instructions assume you are going to use that "example" application to run Solr (the simplest way to get it working quickly).  In production, you may wish to move/copy the "example" folder to a new location.  (e.g. cp solr-1.3.0/example /home/solr).  In that case, adjust your paths 

First rename the stock schema.xml file that comes with the solr example instance:
rename apache-solr-1.3.0/example/solr/conf/schema.xml to something like schema.bak.
 
Now copy the schema.xml that comes with the ApacheSolr Drupal module to take its place in solr/conf:
(e.g. cp /var/www/drupal/sites/all/modules/apachesolr/schema.xml solr-1.3.0/example/solr/conf/)

There are two ways to run Solr, as a standalone application, or inside an enterprise servlet container such as Apache Tomcat.   Standalone is much eaiser to set up, and more suitable for local development and testing, while Tomcat is much harder to set up, but more suitable for use on production webservers.  In standalone mode, Solr only runs as long as the window with the java command is open.  With Tomcat, Solr can be delivered as an always-on service (but again, it's much harder to set up).


Simple install option: Standalone Solr run with a java command:


You can easily start Solr by opening a shell/Terminal Window, changing the directory to apache-solr-1.3.0/example, and executing the command: "java -jar start.jar"

There should be lots of terminal output, ending with something like this:

  INFO: [] Registered new searcher Searcher@5a20f443 main
  2009-09-28 09:17:17.948::INFO:  Started SocketConnector @ 0.0.0.0:8983

That last line says that Solr should now be listening on port 8983 of your computer.

Test this in a web browser by visiting http://<your server address>:8983/solr/admin/, 
(e.g. http://localhost:8983/solr/admin/ )

  Any time you reboot the computer or close the terminal window, you will have to change to the directory and run java -jar start.jar again to start Solr.   You can keep the standalone one running even if you accidentally close the terminal window by using the screen program.  Install screen, then "screen java -jar start.jar" to start the server.  If you close the window, you can re-attach later with "screen -d -r").  This method will not auto-start Solr if the computer reboots, if you need that consider moving up to the Tomcat install.


Advanced/server install option: TomCat Solr Installation run as a service:

Installing TomCat is a subject that varies from operating system to operating system.  You should search for appropriate instructions for your OS to get TomCat working to the point where you can  see the "It works!" page at http://<your server address>:8080.  

In Ubuntu Linux, the latest version at time of this release is tomcat6 and should use sun-java6-jre.  Tomcat6 listens on port 8180 by default.  Debian Lenny uses tomcat5.5 (and should work best with sun-java5-jre).  Tomcat listens on port 8080 by default.

For Fedora / Redhat / CentOS, you may be able to install java-1.6.0-sun package, or you might have to download the RPM package from Sun at java.com and install it manually.


In either case, after Tomcat is installed, it will have a configuration directory containing a subdirectory named "Catalina", with another subdirectory "localhost".  The location of this tomcat configuration directory may change depending on your OS version. In Ubuntu Linux the default configuration directory is "/etc/tomcat6/".  In  Debian Linux the default configuration directory is "/etc/tomcat5.5//"

Create a file in the Catalina/localhost directory called "solr.xml", (e.g. /etc/tomcat6/Catalina/localhost/solr.xml)

If you renamed/moved the "example" instance to a more permanent name, put the proper path and name in solr.xml here!

<Context docBase="/home/myusername/solr-1.3.0/solr/webapps/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/home/myusername/apache-solr-1.3.0/example/solr" override="true"  />
</Context>

After solr.xml is created, you need to turnoff the Java Security Manager (easy) or properly set permissions the solr instance needs in your java environment (hard, not covered here).
Edit /etc/default/tomcat6 and set TOMCAT6_SECURITY=no. 

Now restart Tomcat (sudo /etc/init.d/tomcat6 restart)

Try loading the Solr web administration interface in a web browser:

  http://<your server address>:8080/solr/admin  

If you see a Solr page, you have it working, congratulations!

If you see pages of large print Java exception errors, something is configured wrong.  Try reading through and look for what is wrong.  If it's a permission denied error, make sure you turned off the security manager in TomCat.  If it's complaining about not finding the Solr directory, make sure you set the correct path in solr.xml.  Failing those two, check the Tomcat logs (by default: /var/log/catalina.YYYY-MM-DD.log) and you may find more readable error output.

If you get a server not found, try port 8180 instead of 8080, and otherwise verify that Tomcat is running and you can see the Tomcat "It works!" default page.


Drupal Module Installation and Configuration
--------------------------------------------

Once Solr is running and you can see the administration interface, you can enable and configure the Drupal module.

Install and enable the ApacheSolr Drupal module as you would any Drupal module.  Unpack it to sites/all/modules and visit Administer > Site Building > Modules.  Enable at least "Apache Solr Framework" and
"Apache Solr Search".

Next, configure the module at Administer > Site Configuratin > Apache Solr > Settings.

Set the host name and port of your Solr instance.  Usually localhost will do for a host name, but
the port must match what port you're using:  8983 for standalone, 8080 for Ubuntu Tomcat 5 or 6, and 8180 for Tomcat 6 on Debian Lenny.

The Solr path should be left at the default "/solr".  Now "Save configuration" and if the ApacheSolr module can talk to Solr, a green message will say "Solr can be pinged".  If a red message says "No Solr instance is available", check that Solr is running (you can hit the Solr admin web page in a browser), correct the settings, and try again, until you see the message that Solr can be pinged.


Enable Facet blocks
-------------------
Enable blocks for facets at Administer > Site building > Blocks.   
Turning these blocks on gives users the ability to refine their searches using Faceted Search 
(for more info on faceted searching see: http://en.wikipedia.org/wiki/Faceted_search)


(Optional) Disable Core Search functionality with coresearches
--------------------------------------------------------------
Download the core searches, apply the latest patch for your Drupal version as described in the coresearches README.txt, and then enable Core Search and User Search modules to turn on those search features.  

$ cd /path/to/your/drupal
$ patch -p0 < sites/all/modules/coresearches/DRUPAL-5.20.patch  (you may have to fetch the latest patch for Drupal from http://drupal.org/node/353009)

WARNING - When you update your Drupal version (say for a security update), you will need to re-patch with the latest coresearches patch or you may get a white screen of death!  For this reason you should probably not install coresearches unless you are comfortable with the concept of re-patching your Drupal core files every upgrade.


(Optional) Enable Node Access Support
-------------------------------------
Visit Administer > Site Building > Modues and turn on apachesolr_nodeaccess.
You must re-index the site to see the permissions changes.

If you do not turn on Node Access support, then all content on the site will be returned in Solr search results.  That would probably be fine for a public site, but bad for a private intranet site with private groups.


(Optional, Advanced) Enable Attachment Support
----------------------------------------------
With attachment support, Solr can index the contents of PDF files, Text Files, and Word Documents that are saved as node attachments.

DO NOT JUST TURN ON ATTACHMENT SUPPORT without configuring it properly.  If you don't need it, leave it off!


Enable the apachesolr_attachments module at Administer > Site Building > Modules.
Visit Administer > Site Configuration > Apache Solr > Apache Solr Attachments Settings.

In this 5.x-1.x version, document contents are parsed by several helper applications.  
At least one of these helper applications must be built from source (doctotext).  

You need each the following programs on your system:

"pdftotext" for .PDF files (found in package "poppler-utils" or maybe "xpdf-utils" for Linux)
"catdoc" for .DOC files (found in package "catdoc" for Linux)
"doctotext" for .DOCX" files (install from source using instructions below)
  - download the source package from http://silvercoders.com/index.php?page=DocToText 
  - un tar it, run "make", and it should build you:  build/doctotext
  - test it by running "build/doctotext" with no arguments, it should print help
  - copy that to your path, i.e.  cp build/doctotext /usr/local/bin
  
You can choose not to process one or more of these file types by leaving the entry blank on the Apache Solr Attachments Settings page.

On Debian and Ubuntu the most secure settings are as follows, with doctotext installed in /usr/local/bin:

PDF helper:  /usr/bin/pdftotext "%file%" -
Text helper: /bin/cat "%file%"
MS Word (up to 2004) .doc helper:  /usr/bin/catdoc -a "%file%"
MS Word (2007+) .docx helper:  /usr/local/bin/doctotext "%file%"

Save the configuration.  You have to rebuild the index if you have not already (see below) in
order to see contents inside your attachments.   New attachments will be indexed automatically when cron.php next runs.


Re-Index your site and run cron.php to build the index
-------------------------------------------------------
Usually any new content is added to to the Solr index when cron.php runs.  Becuase we are installing from scratch, the Solr index is empty and you need to build the index by manually running cron.php until the index is 100% built.  (This is especially important if you are installing on a site with lots of existing content otherwise it could take hours or even days for it all to show up in search results).

First wipe the old index, in case cron.php has already started indexing content with the wrong settings (while you were configuring everything):

Visit "Administer > Site Configuration > Search Settings".  Press "Re-index" site and confirm.  The Solr index will be wiped.

Repeatedly run your site's cron.php page in another tab or window until your content is indexed.  cron.php will process 100 nodes per run by default.   After each cron.php run, refresh the admin/settings/search page so you can see what Percentage of the site is indexed. 

Once the Search Settings page reports that 100% of your site content is indexed, you are ready to try some test searches,

Use this procedure if you ever need to re-index everything on the site.  


Sharing one Solr instance shared between many Drupal sites
----------------------------------------------------------
One Solr install can be shared between as many sites as you like, with no special configuration required.

The Drupal apachesolr modules index a signature of the Site URL along with each piece of content content.  Thus a site's search will only return results for its own data, even if you have many sites indexed using the same Solr instance (ie. address, port, and path in ApacheSolr Settings).  

It is also possible to search across all of the sites that are indexed in your Solr, which is known as "Multi-Site search".

To use multi-site search, you must activate the Apache Solr multisite search module, and then searches will search across all sites in your instance.  Note that this is an all-or-nothing feature, you can't turn on multi site searching and only search -some- of the sites in Solr.  If you need to do this, consider running multiple Solr cores, which will give you moe than one instance.  You can then use one for the searchable sites, and one for sites that must not show up in the multi site search.   Finally, multi site searching may produce crazy results when combined with the apache solr node_access module.



Troubleshooting
---------------

Problem: Solr will not run in Tomcat, instead there are just pages of Java errors about security.permissionDenied.

Solution:  Make sure the security manager is disabled in your TomCat policy file.  Edit /etc/default/tomcat6 and set TOMCAT6_SECURITY=no , then restart Tomcat.  See the Tomcat Insatllation instructions above for more help.



Problem:
Your Solr instance is running and you can test it in the Solr 
admin interface (comes with the Java application). Yet your 
Drupal ApacheSolr module cannot connect to it to do a search.

Solution:
To be able to use file_get_contents() in PHP, the "allow_url_fopen" 
directive must be enabled. In php.ini set the following value:
allow_url_fopen = On
Only set this value if you are having problems, as it is against best security practices to do so.



Problem:
I've installed the module but the search resluts are incomplete, and I get only one or two results back from my site.

Solution:
Visit Administer -> Site Configuration > Search Settings and make sure your site is 100% indexed.  If not, run cron.php until it is.  See "Re-Index your site and run cron.php to build the index" above for more information.



Problem:
Administer -> Site Configuration > Search Settings says the site is 100% indexed, but no search results come back.

Solution:
Make sure that cron.php is being called from the EXACT site URL you are using to search.   ApacheSolr will use the URL of the cron.php call to determine the site name.  So for example, if your site is vieuwed at "http://www.example.com' and you call cron as "http://example.com/cron.php" or "http://localhost/cron.php" then ApacheSolr will index the wrong URL and you will not get site results!   Additionally, and for this reason, you should make sure you force users to end up at one definitive URL, with or without the www. prefix.  (One simple way to do this is setting $base_url in the settings.php file, so as soon as users click on anything or log in they will have the correct URL.  A better but much more advanced way is to use an Apache RewriteRule to redirect users as soon as they arrive.)

If that is not the problem, you should try typing search terms into the ApacheSolr admin interface in the large text box, and hitting Search.  You should be able to see results for simple one word searches that match your content.


Problem:
Anonymous users and users without permission are seeing protected content come back in search results, even though they do not have permissions!

Solution:
Ensure that the apachesolr_node_access module is activated.  Then visit Administer > Site Configuration > Search Settings and re-index the site.  Finally, run cron.php until the Search Settings page reports 100% of the content is indexed.  Now test again from anonymous and unprivelaged users.  Solr should only show results for which the current user has permission.



Developer Information
---------------------

Exposed Hooks:

@param &$document Apache_Solr_Document
@param $node StdClass
hook_apachesolr_update_index(&$document, $node)

This hook is called just before indexing the document.
It allows you to add fields to the $document object which is sent to Solr.
For reference on the $document object, see SolrPhpClient/Apache/Solr/Document.php 

File

README.txt
View source
  1. Apache Solr Search Integration 5.x-1.0
  2. REAMDE Contents:
  3. Introduction
  4. Prerequisite Installations
  5. Sun Java 5 + Runtime Environment
  6. Apache Solr 1.3.x
  7. Simple install option: Standalone Solr run with a java command
  8. Advanced/server install option: TomCat Solr Installation run as a service
  9. Drupal Module Installation and Configuration
  10. Enable Facet blocks
  11. (Optional) Disable Core Search functionality with coresearches
  12. (Optional) Enable Node Access Support
  13. (Optional, Advanced) Enable Attachment Support
  14. Re-Index your site and run cron.php to build the index
  15. Sharing one Solr instance shared between many Drupal sites
  16. Troubleshooting
  17. Developer Information
  18. Introduction
  19. ------------
  20. This module integrates Drupal with the Apache Solr search platform. In Drupal, Solr search can be used as a replacement for core content search and boasts both extra features and better performance. Among the extra features are the ability to have faceted search on facets ranging from content author to taxonomy to arbitrary CCK fields, and the abillity to index and "search inside" Acrobat (.pdf), Word 97-2004 (.doc), Word 2007+ (.docx), and Plain Text (.txt) attachments.
  21. For more introductory information on Solr, visit its wikipedia entry and home page:
  22. http://lucene.apache.org/solr/
  23. http://en.wikipedia.org/wiki/Apache_Solr
  24. This module comes with a schema.xml file which should be used in your Solr installation. Follow the installation steps below carefully, as the module will not just work out of the box with a default Solr configuration.
  25. This module depends on the search framework in core. By default, you get results from the core search functionality for content and uesrs, as well as Solr results. If you you do not want the core search capabilities and only want Solr results returned, you need to install the Core Searches module in tandem with this module. See the sectoin "(Optional) Disable Core Search functionality with coresearches", below.
  26. In order to successfully set this all up on a production site, you probably need administrator access to your server, or at least cooperation/help from your system's administrator to get TomCat and Solr configured properly.
  27. Prerequisite Installations
  28. --------------------------
  29. Prerequisite: Sun Java 5 + Runtime Environment
  30. Ideally you should run the official Sun Java JRE and not
  31. one of the various open source alternatives.
  32. On Ubuntu Linux, make sure "multiverse" is enabled in System->Administration->Sofwtare Sources, then install the "sun-java6-jre" or "sun-java6-jdk" packages. After installation use the command: "sudo update-java-alternatives -s java-6-sun" to set the Sun JRE as default. Finally, use "java -version" to make sure you are running the official Java(TM) from Sun.
  33. On Debian Linux, you need to enable "non-free" in your /etc/apt/sources.list and then install the sun-java5-jre package. After installation use "sudo /usr/sbin/alternatives --config java" to set the Sun JRE as the default.
  34. For RedHat/Fedora Core/CentOS, install the java-1.6.0-sun package, or see http://wiki.centos.org/HowTos/JavaOnCentOS for instructions to create it if it is not available. After installation use "sudo /usr/sbin/alternatives --config java" to set the Sun JRE as the default.
  35. for Windows, download the correct JRE and install it for your version of windows and install it.
  36. Once Java is correctly installed, the command "java -version" should show the Sun Java(TM) Header, e.g.
  37. $ java -version
  38. java version "1.6.0_16"
  39. Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
  40. Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
  41. Prerequisite: Apache Solr 1.3.x:
  42. Download the latest Solr 1.3.x release from a mirror site:
  43. http://www.apache.org/dyn/closer.cgi/lucene/solr/
  44. At 1.0 release time, the latest version was apache-solr-1.3.0.tgz.
  45. Unpack the apache_solr-1.3.0.tgz somewhere not visible to the web (not in your apache docroot and not inside of your drupal directory).
  46. $ tar xzvf apache_solr-1.3.0.tgz
  47. The Solr download comes with an example instance (named "example") that you can use as-is for testing, development, and even for smaller production sites. This instance is found in the apache-solr-1.3.0/example folder. These instructions assume you are going to use that "example" application to run Solr (the simplest way to get it working quickly). In production, you may wish to move/copy the "example" folder to a new location. (e.g. cp solr-1.3.0/example /home/solr). In that case, adjust your paths
  48. First rename the stock schema.xml file that comes with the solr example instance:
  49. rename apache-solr-1.3.0/example/solr/conf/schema.xml to something like schema.bak.
  50. Now copy the schema.xml that comes with the ApacheSolr Drupal module to take its place in solr/conf:
  51. (e.g. cp /var/www/drupal/sites/all/modules/apachesolr/schema.xml solr-1.3.0/example/solr/conf/)
  52. There are two ways to run Solr, as a standalone application, or inside an enterprise servlet container such as Apache Tomcat. Standalone is much eaiser to set up, and more suitable for local development and testing, while Tomcat is much harder to set up, but more suitable for use on production webservers. In standalone mode, Solr only runs as long as the window with the java command is open. With Tomcat, Solr can be delivered as an always-on service (but again, it's much harder to set up).
  53. Simple install option: Standalone Solr run with a java command:
  54. You can easily start Solr by opening a shell/Terminal Window, changing the directory to apache-solr-1.3.0/example, and executing the command: "java -jar start.jar"
  55. There should be lots of terminal output, ending with something like this:
  56. INFO: [] Registered new searcher Searcher@5a20f443 main
  57. 2009-09-28 09:17:17.948::INFO: Started SocketConnector @ 0.0.0.0:8983
  58. That last line says that Solr should now be listening on port 8983 of your computer.
  59. Test this in a web browser by visiting http://:8983/solr/admin/,
  60. (e.g. http://localhost:8983/solr/admin/ )
  61. Any time you reboot the computer or close the terminal window, you will have to change to the directory and run java -jar start.jar again to start Solr. You can keep the standalone one running even if you accidentally close the terminal window by using the screen program. Install screen, then "screen java -jar start.jar" to start the server. If you close the window, you can re-attach later with "screen -d -r"). This method will not auto-start Solr if the computer reboots, if you need that consider moving up to the Tomcat install.
  62. Advanced/server install option: TomCat Solr Installation run as a service:
  63. Installing TomCat is a subject that varies from operating system to operating system. You should search for appropriate instructions for your OS to get TomCat working to the point where you can see the "It works!" page at http://:8080.
  64. In Ubuntu Linux, the latest version at time of this release is tomcat6 and should use sun-java6-jre. Tomcat6 listens on port 8180 by default. Debian Lenny uses tomcat5.5 (and should work best with sun-java5-jre). Tomcat listens on port 8080 by default.
  65. For Fedora / Redhat / CentOS, you may be able to install java-1.6.0-sun package, or you might have to download the RPM package from Sun at java.com and install it manually.
  66. In either case, after Tomcat is installed, it will have a configuration directory containing a subdirectory named "Catalina", with another subdirectory "localhost". The location of this tomcat configuration directory may change depending on your OS version. In Ubuntu Linux the default configuration directory is "/etc/tomcat6/". In Debian Linux the default configuration directory is "/etc/tomcat5.5//"
  67. Create a file in the Catalina/localhost directory called "solr.xml", (e.g. /etc/tomcat6/Catalina/localhost/solr.xml)
  68. If you renamed/moved the "example" instance to a more permanent name, put the proper path and name in solr.xml here!
  69. After solr.xml is created, you need to turnoff the Java Security Manager (easy) or properly set permissions the solr instance needs in your java environment (hard, not covered here).
  70. Edit /etc/default/tomcat6 and set TOMCAT6_SECURITY=no.
  71. Now restart Tomcat (sudo /etc/init.d/tomcat6 restart)
  72. Try loading the Solr web administration interface in a web browser:
  73. http://:8080/solr/admin
  74. If you see a Solr page, you have it working, congratulations!
  75. If you see pages of large print Java exception errors, something is configured wrong. Try reading through and look for what is wrong. If it's a permission denied error, make sure you turned off the security manager in TomCat. If it's complaining about not finding the Solr directory, make sure you set the correct path in solr.xml. Failing those two, check the Tomcat logs (by default: /var/log/catalina.YYYY-MM-DD.log) and you may find more readable error output.
  76. If you get a server not found, try port 8180 instead of 8080, and otherwise verify that Tomcat is running and you can see the Tomcat "It works!" default page.
  77. Drupal Module Installation and Configuration
  78. --------------------------------------------
  79. Once Solr is running and you can see the administration interface, you can enable and configure the Drupal module.
  80. Install and enable the ApacheSolr Drupal module as you would any Drupal module. Unpack it to sites/all/modules and visit Administer > Site Building > Modules. Enable at least "Apache Solr Framework" and
  81. "Apache Solr Search".
  82. Next, configure the module at Administer > Site Configuratin > Apache Solr > Settings.
  83. Set the host name and port of your Solr instance. Usually localhost will do for a host name, but
  84. the port must match what port you're using: 8983 for standalone, 8080 for Ubuntu Tomcat 5 or 6, and 8180 for Tomcat 6 on Debian Lenny.
  85. The Solr path should be left at the default "/solr". Now "Save configuration" and if the ApacheSolr module can talk to Solr, a green message will say "Solr can be pinged". If a red message says "No Solr instance is available", check that Solr is running (you can hit the Solr admin web page in a browser), correct the settings, and try again, until you see the message that Solr can be pinged.
  86. Enable Facet blocks
  87. -------------------
  88. Enable blocks for facets at Administer > Site building > Blocks.
  89. Turning these blocks on gives users the ability to refine their searches using Faceted Search
  90. (for more info on faceted searching see: http://en.wikipedia.org/wiki/Faceted_search)
  91. (Optional) Disable Core Search functionality with coresearches
  92. --------------------------------------------------------------
  93. Download the core searches, apply the latest patch for your Drupal version as described in the coresearches README.txt, and then enable Core Search and User Search modules to turn on those search features.
  94. $ cd /path/to/your/drupal
  95. $ patch -p0 < sites/all/modules/coresearches/DRUPAL-5.20.patch (you may have to fetch the latest patch for Drupal from http://drupal.org/node/353009)
  96. WARNING - When you update your Drupal version (say for a security update), you will need to re-patch with the latest coresearches patch or you may get a white screen of death! For this reason you should probably not install coresearches unless you are comfortable with the concept of re-patching your Drupal core files every upgrade.
  97. (Optional) Enable Node Access Support
  98. -------------------------------------
  99. Visit Administer > Site Building > Modues and turn on apachesolr_nodeaccess.
  100. You must re-index the site to see the permissions changes.
  101. If you do not turn on Node Access support, then all content on the site will be returned in Solr search results. That would probably be fine for a public site, but bad for a private intranet site with private groups.
  102. (Optional, Advanced) Enable Attachment Support
  103. ----------------------------------------------
  104. With attachment support, Solr can index the contents of PDF files, Text Files, and Word Documents that are saved as node attachments.
  105. DO NOT JUST TURN ON ATTACHMENT SUPPORT without configuring it properly. If you don't need it, leave it off!
  106. Enable the apachesolr_attachments module at Administer > Site Building > Modules.
  107. Visit Administer > Site Configuration > Apache Solr > Apache Solr Attachments Settings.
  108. In this 5.x-1.x version, document contents are parsed by several helper applications.
  109. At least one of these helper applications must be built from source (doctotext).
  110. You need each the following programs on your system:
  111. "pdftotext" for .PDF files (found in package "poppler-utils" or maybe "xpdf-utils" for Linux)
  112. "catdoc" for .DOC files (found in package "catdoc" for Linux)
  113. "doctotext" for .DOCX" files (install from source using instructions below)
  114. - download the source package from http://silvercoders.com/index.php?page=DocToText
  115. - un tar it, run "make", and it should build you: build/doctotext
  116. - test it by running "build/doctotext" with no arguments, it should print help
  117. - copy that to your path, i.e. cp build/doctotext /usr/local/bin
  118. You can choose not to process one or more of these file types by leaving the entry blank on the Apache Solr Attachments Settings page.
  119. On Debian and Ubuntu the most secure settings are as follows, with doctotext installed in /usr/local/bin:
  120. PDF helper: /usr/bin/pdftotext "%file%" -
  121. Text helper: /bin/cat "%file%"
  122. MS Word (up to 2004) .doc helper: /usr/bin/catdoc -a "%file%"
  123. MS Word (2007+) .docx helper: /usr/local/bin/doctotext "%file%"
  124. Save the configuration. You have to rebuild the index if you have not already (see below) in
  125. order to see contents inside your attachments. New attachments will be indexed automatically when cron.php next runs.
  126. Re-Index your site and run cron.php to build the index
  127. -------------------------------------------------------
  128. Usually any new content is added to to the Solr index when cron.php runs. Becuase we are installing from scratch, the Solr index is empty and you need to build the index by manually running cron.php until the index is 100% built. (This is especially important if you are installing on a site with lots of existing content otherwise it could take hours or even days for it all to show up in search results).
  129. First wipe the old index, in case cron.php has already started indexing content with the wrong settings (while you were configuring everything):
  130. Visit "Administer > Site Configuration > Search Settings". Press "Re-index" site and confirm. The Solr index will be wiped.
  131. Repeatedly run your site's cron.php page in another tab or window until your content is indexed. cron.php will process 100 nodes per run by default. After each cron.php run, refresh the admin/settings/search page so you can see what Percentage of the site is indexed.
  132. Once the Search Settings page reports that 100% of your site content is indexed, you are ready to try some test searches,
  133. Use this procedure if you ever need to re-index everything on the site.
  134. Sharing one Solr instance shared between many Drupal sites
  135. ----------------------------------------------------------
  136. One Solr install can be shared between as many sites as you like, with no special configuration required.
  137. The Drupal apachesolr modules index a signature of the Site URL along with each piece of content content. Thus a site's search will only return results for its own data, even if you have many sites indexed using the same Solr instance (ie. address, port, and path in ApacheSolr Settings).
  138. It is also possible to search across all of the sites that are indexed in your Solr, which is known as "Multi-Site search".
  139. To use multi-site search, you must activate the Apache Solr multisite search module, and then searches will search across all sites in your instance. Note that this is an all-or-nothing feature, you can't turn on multi site searching and only search -some- of the sites in Solr. If you need to do this, consider running multiple Solr cores, which will give you moe than one instance. You can then use one for the searchable sites, and one for sites that must not show up in the multi site search. Finally, multi site searching may produce crazy results when combined with the apache solr node_access module.
  140. Troubleshooting
  141. ---------------
  142. Problem: Solr will not run in Tomcat, instead there are just pages of Java errors about security.permissionDenied.
  143. Solution: Make sure the security manager is disabled in your TomCat policy file. Edit /etc/default/tomcat6 and set TOMCAT6_SECURITY=no , then restart Tomcat. See the Tomcat Insatllation instructions above for more help.
  144. Problem:
  145. Your Solr instance is running and you can test it in the Solr
  146. admin interface (comes with the Java application). Yet your
  147. Drupal ApacheSolr module cannot connect to it to do a search.
  148. Solution:
  149. To be able to use file_get_contents() in PHP, the "allow_url_fopen"
  150. directive must be enabled. In php.ini set the following value:
  151. allow_url_fopen = On
  152. Only set this value if you are having problems, as it is against best security practices to do so.
  153. Problem:
  154. I've installed the module but the search resluts are incomplete, and I get only one or two results back from my site.
  155. Solution:
  156. Visit Administer -> Site Configuration > Search Settings and make sure your site is 100% indexed. If not, run cron.php until it is. See "Re-Index your site and run cron.php to build the index" above for more information.
  157. Problem:
  158. Administer -> Site Configuration > Search Settings says the site is 100% indexed, but no search results come back.
  159. Solution:
  160. Make sure that cron.php is being called from the EXACT site URL you are using to search. ApacheSolr will use the URL of the cron.php call to determine the site name. So for example, if your site is vieuwed at "http://www.example.com' and you call cron as "http://example.com/cron.php" or "http://localhost/cron.php" then ApacheSolr will index the wrong URL and you will not get site results! Additionally, and for this reason, you should make sure you force users to end up at one definitive URL, with or without the www. prefix. (One simple way to do this is setting $base_url in the settings.php file, so as soon as users click on anything or log in they will have the correct URL. A better but much more advanced way is to use an Apache RewriteRule to redirect users as soon as they arrive.)
  161. If that is not the problem, you should try typing search terms into the ApacheSolr admin interface in the large text box, and hitting Search. You should be able to see results for simple one word searches that match your content.
  162. Problem:
  163. Anonymous users and users without permission are seeing protected content come back in search results, even though they do not have permissions!
  164. Solution:
  165. Ensure that the apachesolr_node_access module is activated. Then visit Administer > Site Configuration > Search Settings and re-index the site. Finally, run cron.php until the Search Settings page reports 100% of the content is indexed. Now test again from anonymous and unprivelaged users. Solr should only show results for which the current user has permission.
  166. Developer Information
  167. ---------------------
  168. Exposed Hooks:
  169. @param &$document Apache_Solr_Document
  170. @param $node StdClass
  171. hook_apachesolr_update_index(&$document, $node)
  172. This hook is called just before indexing the document.
  173. It allows you to add fields to the $document object which is sent to Solr.
  174. For reference on the $document object, see SolrPhpClient/Apache/Solr/Document.php