This is an introductory guide to setting up Solr and then switching Liferay Portal's indexing method to Solr. Keep in mind that this is only one step in creating a cluster for use with Liferay Portal. For further instruction, see Installing Liferay Portal in a Clustered Environment.
Note: Want to see the same process using Tomcat? Read Installing SOLR on a Two-Node Cluster.
Solr is an open source enterprise search server based on the Lucene Java search library, with XML/HTTP and JSON APIs, hit highlighting, faceted search, caching, replication, and a web administration interface. Solr allows the administrator to search structured data without needing to write any custom code.
Pros
- Overall, has the best performance for clustering the indexes
- Offloads the burden of indexing from the Liferay nodes
- Centralized index repository
- Solr has more configuration options that make customization easier
Cons
- If the Solr box goes down, all nodes will have no index. However, there is a distributed/replication setup that gives Solr high availability. Learn More by reading Scaling Lucene and Solr.
- Fairly involved configuration/setup
Resolution
In this bare-minimum guide, we'll set up three nodes:
- The Solr Node—The node that will do the indexing for the Liferay Portal nodes.
- Node 1—This node is running Liferay Portal and is clustered with node 1.
- Node 2—This node is running Liferay Portal and is clustered with node 2.
Setting up the Solr Node
- Download apache-solr-1.4.0.zip and unzip its contents.
- Create your
$SOLR_HOME
directory, for instanceC:\Program Files\Solr
. - Navigate to
apache-solr-1.4.0\example
and copy the contents of the "solr" folder into your$SOLR_HOME
. - Copy the WAR file from the Solr folder you downloaded; it is located in
$APACHE-SOLR/dist/apache-solr-${solr.version}.war
into$TOMCAT_HOME/webapps
where${solr.version}
represents Solr version number, i.e., 1.4.0. - Rename the
.war
file to something easier, such assolr.war
(the name will matter later). - Add the following line to your
$TOMCAT_AS_DIR/bin/catalina.bat
.- set
JAVA_OPTS=%JAVA_OPTS% -Dsolr.solr.home="C:\Program Files\Solr"
- set
- Run JBoss and visit the Solr Admin page to verify it runs correctly.
Setting up Node 1
- Start a Liferay Portal 6.1 EE GA2 bundle (using tomcat) and deploy
solr-web-6.1.20.2-ee-ga2-20121226141007185.war
- Open the
.war
archive and edit the filesolr-spring.xml
, which is located in$SOLR_WAR\WEB-INF\classes\META-INF\
- Shutdown JBoss / Solr. Copy the Schema located in
$SOLR_WAR\WEB-INF\conf\
and place it in the$SOLR_HOME/conf
(you may have to create the conf directory) on your Solr box. Now you can go ahead and start JBoss / Solr. - Deploy the Liferay Solr
.war
with the editedsolr-spring.xml
into Tomcat-Liferay bundle
Testing SOLR
- Create a Wiki.
- Navigate to the Solr admin webpage, and search for a term that is contained in your portal's contents.
Result
You should see assets with that term in your search results.