Installing and Configuring Solr 4 in Liferay Portal 6.2

The following article outlines a step-by-step guide of connecting Liferay Portal 6.2 EE to Solr 4.3.1 for the purpose of testing. Please note that for Liferay Portal 6.2 EE, the supported versions of Solr 4 are versions 4.3.1 through 4.10.2.


Follow the steps below to start Solr along with Liferay Portal 6.2 EE, and connect them via the Liferay Solr 4 Search Engine app that is available on Liferay Marketplace.

  1. Download and unzip Solr 4.3.1 to a convenient location. Treat the root of the unzipped Solr as SOLR_HOME
  2. Navigate to SOLR_HOME/example and execute java -jar start.jar
  3. Your solr server is now running (on Jetty) on port 8983. If you wish to do so, you may change the port in SOLR_HOME/example/etc/jetty.xml. This article assumes you have not changed the port from the default value.
  4. Navigate to http://localhost:8983/solr to validate if Solr is running properly.
  5. Once you’ve confirmed that the server is running, stop the Solr server.
  6. Start up Liferay Portal 6.2 EE. Treat the root of the bundle as $liferay-home
  7. Download the Liferay Solr 4 Search Engine app from the marketplace and deploy it to the portal.
  8. Once the plugin is deployed, stop the portal.
  9. Copy the $liferay-home/webapps/solr4-web/WEB-INF/conf/schema.xml to $solr-home/example/solr/collection1/conf
  10. Copy the $liferay-home/webapps/solr4-web/WEB-INF/conf/solrconfig.xml to $solr-home/example/solr/collection1/conf
  11. If you are using Liferay Solr 4 Search Engine 2.1.0 or later:
    1. Create TOMCAT_HOME/webapps/solr4-web/WEB-INF/classes/ with the following content: server.http.url=http://localhost:8983/solr
    2. Save
  12. If you are using an older version of the Liferay Solr 4 Search Engine plugin:
    1. Navigate to LIFERAY_HOME/tomcat-7.0.62/webapps/solr4-web/WEB-INF/classes/META-INF and edit the file called solr-spring.xml. Look for the following snippet 8080/solr" /> and replace it with 8983/solr" />
    2. Save
  13. Start the Solr server
  14. Start Liferay Portal
  15. Navigate to Liferay Portal Control Panel > Server Administration and execute a full re-index, Reindex search indexes.


To test the whether the connection is alive, check Solr’s log. Every 10 seconds the Liferay Portal will ping the Solr server, which shows up in Solr’s log as such:

395631 [qtp227416342-15] INFO org.apache.solr.core.SolrCore – [collection1] webapp=/solr path=/admin/ping params={wt=javabin&version=2} hits=0 status=0 QTime=1

395631 [qtp227416342-15] INFO org.apache.solr.core.SolrCore – [collection1] webapp=/solr path=/admin/ping params={wt=javabin&version=2} status=0 QTime=1

To see if the re-index was successful, navigate to Solr’s admin page and select Collection1 from the drop-down menu. Click on Query, then on Execute Query. Solr should show you everything it has indexed so far:


Common Issues

Not Enough Memory

By default, Jetty starts with 4g heap size and 82mb Perm size. If for some reason this is not enough for your test scenario, you can change the allocated memory by specifying additional parameters:

java -jar -Xmx8g -XX:MaxPermSize=128m start.jar

Note: You can check the memory allocations by running jmap -heap

undefined field _

In Solr’s log:

ERROR org.apache.solr.core.SolrCore – org.apache.solr.common.SolrException: undefined field companyId

In Liferay’s log:

WARN [liferay/search_writer/SYSTEM_ENGINE-1][ProxyMessageListener:81] undefined field companyId
  • Make sure you have copied the schema.xml from the Solr EE plugin to the Solr server (see step 9 above).
  • If the schema.xml is updated, you will need to restart the Solr server.

Liferay Cannot Reach the Solr Server

In Liferay’s log:

WARN [liferay/search_writer/SYSTEM_ENGINE-2][ProxyMessageListener:81] Server at http://localhost:8080/solr returned non ok status:503, message:Service Unavailable
  • Make sure you have modified the solr-spring.xml to point to the correct location (see step 8 above).
  • If you modified the solr-spring.xml, you will need to restart Liferay Portal.

Additional Information

  1. Why do I need to install Solr on a separate application server? Can't I install it in conjunction with Liferay?

    Sure you could, but that defeats the purpose of using Solr, because the goal is to offload search indexing to another box in order to free up processing for your Liferay installation(s).

  2. Why do I get "SolrException: Bad Request" errors?

    You most likely forgot add the Schema.xml from the Liferay Solr plugin .war to the $SOLR_HOME/conf.

  3. Why do I get "SolrException: Not Found" errors?

    You most likely set the URL of the Solr home incorrectly in the Solr-Spring.xml.

  4. How do I migrate from Lucene?

    Simply follow the above steps and reindex (there aren't any special "migration" steps). In regards to the reindex:

  5. How long will the reindexing take?

    It depends on many factors: the size of the data to be re-indexed, the Solr server's JVM settings and application configurations as well as the deployment type of your Solr instance: single-node or SolrCloud. The usual time it takes to reindex your full portal using the default Lucene engine can provide a rough estimation.
    You can find more information about Solr's performance here:

  6. Is there a way to reindex without taking the production down?

    Yes. Switching to Solr on a running Liferay server is a seamless process and doesn't require to take the production server down as long as both Liferay's Solr plugin and the Solr server are properly configured.

  7. What will happen to my portal while the reindexing has taken place?

    There is no difference between the default Lucene engine and Solr server in terms of Liferay portal's availability during reindexing: until the process is finished, searches may yield zero results or incorrect counts. Therefore, it's better to schedule the full-server reindex at a time when the load on your server is lowest.

1 人中有 1 人觉得有帮助