Friday, June 6, 2014

Integrating Solr with Liferay 6

Building Solr & Installing Solr instance on tomcat.
  1. Download Solr-1.3.0 release from Solr.
  2. Unzip .tar on some location. For eg. /opt/solr/
  3. Make /opt/solr/example/solr as a $SOLR_HOME.
  4. Copy apache-solr-1.3.0.war file from /opt/solr/dist and paste it into /opt/solr/example/solr.
  5. Open up the /opt/solr/example/solr/conf/solrconfig.xml
    Replace
    <dataDir>${solr.data.dir: ./solr/data}</dataDir>
    by following 
    <dataDir>${solr.data.dir:/opt/solr/example/solr/data}</dataDir>
    Note: The dataDir can also be temporarily overridden with the JAVA_OPTS environment variable  prior to starting Tomcat
             export JAVA_OPTS="$JAVA_OPTS -Dsolr.data.dir=/opt/solr/example/solr/data"
  1. It is recommended to run the Solr instance on separate tomcat instance other than liferay tomcat.
  2. So for separate tomcat for solr, consider it here. $SOLR_TOMCAT
  3. Into $SOLR_TOMCAT/conf/Catalina/localhost , create one solr.xml file and copy following content into the file and save it.
    <?xml version="1.0" encoding="utf-8"?>
    <Context docBase="/opt/solr/example/solr/apache-solr-1.3.0.war" debug="0" crossContext="true">
    <Environment name="solr/home" type="java.lang.String" value="/opt/solr/example/solr" override="true"/>
    </Context>

    Now start tomcat and check that it is running without any error or not.
 Integrating Solr plugin with Liferay.
  1. Download Solr plugin which is compatible with the Liferay version.
  2. Drop the plugin into $LIFERAY_HOME/deploy directory.
  3. Start liferay tomcat server. After started liferay tomcat, just stop both the tomcat servers (SOLR_TOMCAT and LIFERAY_TOMCAT).
  4. Openup the $LIFERAY_HOME/tomcat-6.0.18/webapps/solr-web/WEB-INF/classes/META-INF/solr-spring.xml
           for bean id=”solrServer” give the solar tomcat settings and save it.
           for eg. http://localhost:8181/solr
  1. Copy the $LIFERAY_HOME/tomcat-6.0.18/webapps/solr-web/WEB-INF/conf/schema.xml file and paste it into /opt/solr/example/solr/conf/ directory.
--------Thanks to Amit Doshi

No comments:

Post a Comment