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 or 3.3.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

• You may have to move up the "bin" and "conf" folders from $SOLR_HOME/example/solr/ to $SOLR_HOME/example.

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.

• Change library from your downloaded version of solr otherwise this plugin only index the data but not search any. If you using solr3.1 get solr library and change the plugin's $AS_WEB_APP_HOME/solr-web/WEB-INF/lib delete first

solr-common.jar 

solr-solrj.jar

then add your current versions solr library for example

apache-solr-solrj-3.1.0.jar or

apache-solr-solrj-3.3.0.jar

High Availability #

Please see the attachments section for an overview of how to ensure high availability with SOLR. This is a general overview, which will give you the idea of how to setup your network to support a stable search environment in Liferay.

Related Articles #

Pluggable Enterprise Search with Solr

1 画像の固定
107096 参照数
平均 (3 投票)
平均評価は5.0星中の5です。
コメント
コメント 作成者 日時
. Note that Liferay portal version must be 5.3... Arvind Mishra 2009/12/08 14:11
It has been changed to "6.0 or above" so I... Thomas Kellerer 2010/02/02 1:58
I worked on using solr as Search engine in... Rishi Dev Gupta 2010/02/07 23:22
Hi, I am very interested on how you... Dominique Béjean 2010/12/16 7:07
I have some problems with SOLR 3.2... Bartlomiej Knabel 2011/06/22 6:50
So is it that these steps won't work for... Madhu Yadav 2010/02/24 5:52
Madhu, solr-web-6.0.1.1.war is availble and it... 匿名 2010/05/21 9:39
Your link to the intranet book (Liferay Portal... Juan Fernández 2009/12/10 7:53
Followed instructions to the dot. Able to start... Nischala Kale 2010/01/21 17:58
I am using Liferay 6.0.5 with solr-web-6.0.5.1,... Ravi Kumar Gupta 2010/10/16 22:44
I am sorry if I was wrong, its true that I can... Ravi Kumar Gupta 2010/10/16 22:56
Okay one more thing, I reindexed all search... Ravi Kumar Gupta 2010/10/16 23:48
solr-web-6.0.0.1.war is not working with... Ravi Kumar Gupta 2010/10/19 20:24
Hi Ravi, I am having same issue. When i reindex... Rajender Reddy Nagulapalle 2014/02/23 14:16
With Solr 141, Tomcat-6.0.29+Liferay 6.0ee... Lulu Liu 2011/08/16 23:47
So will this work for 5.2.3 as well? The... Namrata Hangal 2012/05/08 3:33
A quick question - To ascertain that solr has... Namrata Hangal 2012/05/23 21:02
I followed all the steps above mentioned but I... Debasis Padhi 2012/09/17 0:30
Hi, I followed the steps you mentioned. I can... Mahesh Narke 2013/12/04 0:03
I am unable to download solr-web-6.0.0.1.war or... Kashif Ayyaz Haider 2013/12/19 3:32
You can download it from the Liferay market... Mahesh Narke 2013/12/19 22:00

. Note that Liferay portal version must be 5.3 or above.
I guess it should be version 5.2.3
投稿日時:09/12/08 14:11
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
投稿日時:09/12/10 7:53
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!
投稿日時:10/01/21 17:58
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
Arvind Mishraへのコメント。投稿日時:10/02/02 1:58
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.
Thomas Kellererへのコメント。投稿日時:10/02/07 23:22
So is it that these steps won't work for 5.2.3+?
When is 6.0 being released?
Thomas Kellererへのコメント。投稿日時:10/02/24 5:52
Madhu,
solr-web-6.0.1.1.war is availble and it is working with liferay 6.0.1.

Brian Ko
Madhu Yadavへのコメント。投稿日時:10/05/21 9:39
I am using Liferay 6.0.5 with solr-web-6.0.5.1, It seems that Solr is running fine but Liferay doesn't seem to use solr, since lucene folder is being created and cant see any changes in the solr directory.

Please help
投稿日時:10/10/16 22:44
I am sorry if I was wrong, its true that I can not see any activity to Solr directory. And if I delete lucene, its re created.

But if I stop solr server, and try to reindex all search indexes, Liferay is throwing exceptions, it seems to find solr and when it doesnt get it, says, java.net.connectexception.. seems like Liferay is using Solr, but then where does solr keep all the indexes.. and why liferay has to keep lucene directory... please answer..
ravi kumar guptaへのコメント。投稿日時:10/10/16 22:56
Okay one more thing, I reindexed all search indexes. After that I searched for some keywords in Solr Admin and I got results. This means, its working fine. Solr is running and liferay is using it..

Regards
ravi kumar guptaへのコメント。投稿日時:10/10/16 23:48
solr-web-6.0.0.1.war is not working with Liferay 6.0.1 CE but solr-web-6.0.5.1 works fine with both LR 6.0.5 and 6.0.1 CE.

emoticon
ravi kumar guptaへのコメント。投稿日時:10/10/19 20:24
Hi,

I am very interested on how you implemented direct search into solr with solrj an more particulary how you deal with security and also how you rebuild the url to documents.

Is it possible to have more information ?

Thank you
Rishi Dev Guptaへのコメント。投稿日時:10/12/16 7:07
I have some problems with SOLR 3.2
http://www.liferay.com/community/forums/-/message_boards/message/9533736
Dominique Béjeanへのコメント。投稿日時:11/06/22 6:50
Lulu Liu
With Solr 141, Tomcat-6.0.29+Liferay 6.0ee bundle, I had to change solr.xml to

<?xml version="1.0" encoding="utf-8"?>

<Context docBase="$SOLR_HOME/example/apache-solr-1.4.1.war" debug="0" crossContext="true">

<Environment name="solr/home" type="java.lang.String" value="$SOLR_HOME/example/solr" override="true"/>

</Context>
Lulu
投稿日時:11/08/16 23:47
So will this work for 5.2.3 as well? The article reads 6.0+ and some of us are still not sure...
Lulu Liuへのコメント。投稿日時:12/05/08 3:33
A quick question -
To ascertain that solr has been used for indexing, is it necessary to see the SolrIndexer (if there is anything like that?) in liferay's console instead of LuceneIndexer?
I'm trying to integrate solr 1.4.1 with liferay 6.1 on jboss 5.1
投稿日時:12/05/23 21:02
I followed all the steps above mentioned but I don't know why I got the following exception:

ERROR: cannot set an index-time boost

Is there is any other settings for this which I have to do ?
投稿日時:12/09/17 0:30
Hi,
I followed the steps you mentioned. I can successfully run solr and liferay..Made changes in solr-spring file also.
But when i try to reindex , it say
Reindexing lucene started...
Can you tell me where i am possibly wrong?
投稿日時:13/12/04 0:03
I am unable to download solr-web-6.0.0.1.war or solr-web-6.0.1.1.war, please provide updated link
投稿日時:13/12/19 3:32
You can download it from the Liferay market place. Check portlet for your Liferay version.
https://www.liferay.com/marketplace/-/mp/application/15193648.
Kashif Ayyaz Haiderへのコメント。投稿日時:13/12/19 22:00
Hi Ravi,
I am having same issue. When i reindex its still using lucene but when i search using search portlet its trying to find through solr. Do you know how to fix this issue. I am using Liferay 6.1.1CE GA2, solr 1.4.1 and solr plugin solr-web-6.1.0.1-ce-ga1-20120106155615760.war
ravi kumar guptaへのコメント。投稿日時:14/02/23 14:16