Wiki

Main | Proposals

Integrate Solr with Liferay portal

Introduction#

Solr is the popular, blazing fast open source enterprise search platform from the Apache Lucene project. Its major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering, database integration, and rich document (e.g., Word, PDF) handling. Solr is highly scalable, providing distributed search and index replication, and it powers the search and navigation features of many of the world's largest internet sites. Refer to Apache Solr.

This article shows how to integrate Solr within Liferay Portal. Note that Liferay portal version must be 6 or above.

And moreover, this article is abstracted from the book: Liferay Portal 6 Enterprise Intranets

Install Solr Instance#

In five steps, you could install the Solr example as an instance under Tomcat. Of course, you can find similar installation processes for JBoss, Jetty, Resin, WebSphere, Weblogic, etc.

• Download the latest version of Solr from http://lucene.apache.org/solr/; install it and mark the root of installation folder as the variable $SOLR_HOME.

• Copy the WAR file $SOLR_HOME/dist/apache-solr-${solr.version}.war into $SOLR_HOME/example; where ${solr.version} represents Solr version number, i.e., 1.4.0.

• Create a Tomcat Context fragment called solr.xml with following lines.

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="$SOLR_HOME/example/apache-solr-${solr.version}.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="$SOLR_HOME/example" override="true"/>
</Context>

• Drop the file solr.xml into the folder $TOMCAT_AS_DIR/conf/Catalina/localhost

• Add following line at the end of $TOMCAT_AS_DIR/bin/setenv.sh for Linux or MacOS as follows.

JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=$SOLR_HOME/example/solr/data"
Or add following line at the end of $TOMCAT_AS_DIR/bin/setenv.bat for Windows as follows;
set JAVA_OPTS=%JAVA_OPTS% -Dsolr.solr.home=$SOLR_HOME/example/solr/data

Repeat the above steps with different installation directories to run multiple instances of Solr side-by-side. Starting Tomcat, the Solr admin should be available at http://${solr.host.domain}:${solr.port.number}/solr/admin, where ${solr.host.domain} represents Solr instance domain name, like locahost; ${solr.port.number} represents Solr instance port; number, like 8080.

Configure Solr plugin#

Once the Solr instance was set, you can install the Solr plugin in the portal. How does it work? The following is a sample which could bring the plugin Solr into the portal.

• Download WAR file ${solr.web.war} from

solr-web-6.0.0.1.war

or

solr-web-6.0.1.1.war

• Drop the WAR file ${solr.web.war} to the folder $LIFERAY_HOME/deploy when the portal is running.

After deploying successfully, you should shut down the portal and Solr instance, and moreover, configure the Solr instance with the Solr plugin as follows.

• Open $AS_WEB_APP_HOME/solr-web/WEB-INF/classes/META-INF/solr-spring.xml and update Solr instance settings as follows.

<bean id="solrServer" class="com.liferay.portal.search.solr.server.BasicAuthSolrServer">
 <constructor-arg type="java.lang.String" value=" http://${solr.host.domain}:${solr.port.number}/solr" />
</bean>

• Drop the schema file schema.xml from $AS_WEB_APP_HOME/solr-web/WEB-INF/conf to $SOLR_HOME/example/solr/conf in the domain ${solr.host.domain} – replacing the exiting the schema file schema.xml; and restart Solr instance and the portal.

Pluggable Enterprise Search with Solr

4448 Views , 0 Attachments 0 Attachments

Average (2 Votes)
Comments Flat View

. Note that Liferay portal version must be 5.3 or above.
I guess it should be version 5.2.3

Posted on 12/8/09 2:11 PM.

Top Top
Your link to the intranet book (Liferay Portal 5.3 Enterprise Intranets) points to "Liferay Portal 5,2 Systems Development"... this is a bit confusing
Regards

Posted on 12/10/09 7:53 AM.

Top Top
Followed instructions to the dot. Able to start the Solr Server and Liferay Tomcat; There are no errors, but the Liferay installation still appears to use Lucene - calls are not being logged by the Solr Server, instead, it is rebuilding the Lucene indexes (data\lucene folder is being recreated).

Double-checked solr-spring.xml - it is pointing to the Solr Server instance; in fact, I replaced the file in my solr war file. The war file does get deployed (after copying to LiferayHome/Deploy); also tried using Plugin Installer portlet to no avail.

I tried with solr-web-5.3.0.1.war, and also using solr-web-5.2.0.1.war.

Any pointers as to what is going wrong?

Thanks!

Posted on 1/21/10 5:58 PM.

Top Top
It has been changed to "6.0 or above" so I guess the initial "5.3 or above" was correct.

In a nutshell: it does not seem to be possible with a released version - at least that's the way I read this statement

Posted on 2/2/10 1:58 AM in reply to Arvind Mishra.

Top Top
I worked on using solr as Search engine in order to replace the existing Liferay search portlet.

It was sometime mid last of 2009, What I did was I deployed solr was with Jboss and on top SolrJ (client for Solr) created the interface using REST api. Now whenever any CRUd is done through my custom portlets the information is stored/indexed in Solr database. The I changed the default behaviour of Search portlet so that every search request should fetch data from Solr database only.

But this article is really good to fully integarate Solr with Liferay Stack.

Posted on 2/7/10 11:22 PM in reply to Thomas Kellerer.

Top Top
So is it that these steps won't work for 5.2.3+?
When is 6.0 being released?

Posted on 2/24/10 5:52 AM in reply to Thomas Kellerer.

Top Top
Madhu,
solr-web-6.0.1.1.war is availble and it is working with liferay 6.0.1.

Brian Ko

Posted on 5/21/10 9:39 AM in reply to Madhu Yadav.

Top Top