Thursday, October 10, 2013

Solr Configuration With Liferay

Hi Liferay Mastreo,

Solr Configuration with lifeary is so easy. here i describable  the steps which i follow for solr configuration with liferay 6.0.


1) Download Solr let-test version from here...

2) Download Apache let-test tomcat for solr (separate from liferay tomcat) from here...

3) Unzip .tar/.zip file of Solr which you downloaded version(in step 1) on your prefered location (ex. D:/Solr)

4) Unzip .tar/.zip file of Solr tomcat which you downloaded version(in step 2)on your preferred location (ex. D:/tomcat)

Configuration Solr with tomcat instance

5) apache-solr-1.4.0.war : copy this file from solr dist directory (here D:/Solr/dist) and past into /example/solr(here D:/Solr/example/solr) directory.

6) Configure Solr data directory path into solrconfig.xml (D:/Solr/exmple/solr/conf/solrconfig.xml)
  - Create directory called data into /example/solr/ (here D:/Solr/example/solr)
  - find <dataDir> tag update path of data directory  in ${solr.data.dir:DATA_PATH}
    (here DATA_PATH in our case D:/Solr/example/solr/data so ${solr.data.dir:D:/Solr/example/solr/data})

7) Create solr.xml into D:/tomcat/tomcat****/conf/Catalina/localhost with below content...
      <?xml version="1.0" encoding="utf-8"?>
      <Context docBase="SOLR_WAR_PATH" debug="0" crossContext="true">
        <Environment name="solr/home" type="java.lang.String" value="SOLR_HOME_PATH" override="true"/>
      </Context>
     ( here,
      SOLR_WAR_PATH is D:/Solr/example/solr/apache-solr-1.4.0.war
      SOLR_HOME_PATH is D:/Solr/example/solr)
8) Now start Solr tomcat from D:/tomcat/tomcat****/bin
9) After start successful of tomcat open solr server in your browser with this link
    http://localhost:port/solr (ex http://localhost:8081/solr)
    If you seen "Welcome to Solr!" screen with "Solr Admin" link then congratulation solr   configuration is done successfully.

Integration/Configuration of Solr plug-in with liferay

1) Download solr-plugin war file for liferay supported version from here ...

2) Put solr-plugin war file into "$LIFERAY_HOME/deploy" directory

3) Start Liferay tomcat to deploy solr plugin into portal.

4) Once liferay tomcat start successful. then stop both liferay tomcat and solr tomcat instance
      NOTE: Now liferay webapps contain "/solr-web" directory

5) Open solr-spring.xml from the $LIFERAY_HOME/tomcat/webapps/solr-web/WEB-INF/classes/META-INF

6) Find string {class="com.liferay.portal.search.solr.server.BasicAuthSolrServer"} which is in one of <bean> entry.

7) Inside that <bean> chagne the value as "solr_url" in value attribute of <constructor-arg />   e.g. <constructor-arg type=”java.lang.String” value=”http://localhost:8081/solr” /> 

8) Replace solr instance schema.xml copy from $LIFERAY_HOME/tomcat/webapps/solr-web/WEB-INF/conf/schema.xml  and paste into $SOLR_HOME/exmple/solr/conf

Finally you have done with configuration of solr with Liferay.

Now, Let's confirm weather is it correct configuration or wrong?  by follow below steps.
1) Open Solr tomcat instance first then liferay tomcat instance

2) Goto control_panel -> server administartion-> reindex all data from here

3) Look into solr tomcat server log : solr log change during reindexe from liferay server
   if it's change it means solr configuration is perfect.


That's it.
Enjoy with Solr!!

Note: here solr tomcat port is change to 8081 because both server not start at same time with same port number. you can change according to that.