Monday, 6 July 2015

Solr integration with liferay 6.2

How to setup Solr Server on Tomcat :

- Download Solr from apache website. Here we are using solr 4.*.*.
- Download tomcat from apache website.
- Create one folder called "solr" under base directory.
- Unzip both files on solr folder.
- Copy solr<version>.war from <extracted_solr>\dist to <extracted_tomcat>\webapps and rename solr<version>.war to solr.war.
- Copy all jars in <extracted_solr>\example\lib\ext to <extracted_tomcat>\lib.
- Make changes in server.xml file if you want to change the default http port of tomcat server.
- Start the tomcat.
- Check New folder names solr would be available in webapps.
- Shutdown the tomcat.
- Modify web.xml located at <extracted_tomcat>\webapps\solr\WEB-INF
Uncomment below entry and update the path for solr\home.
<env-entry>        <env-entry-name>solr/home</env-entry-name> <env-entry-value><extracted_solr>/example/solr</env-entry-value>      <env-entry-type>java.lang.String</env-entry-type></env-entry>
- Start the tomcat and access the below URL.
      http://[IP ADDRESS]:[PORT]/solr 

How to setup solr-web plugins in liferay :

- Start the Tomcat server from Liferay Bundle.
- Login with administrator
- Go to admin -> control panel -> App Manager -> Store
- Login with liferay credentials.
- Select your liferay version and search solr keyword.You can see solr plugin.
- Install solr plugin
- After solr-web plugin is deployed in Liferay, stop Liferay Tomcat server. Also stop the Solr Tomcat server which we have setup earlier on a separate tomcat instance.
- Go to <extracted_tomcat>/tomcat-7.0.27/webapps/solr-web/WEB-INF/conf directory.
- Copy and replace schema.xml file to <extracted_solr>example/solr/collection1/conf directory on Solr Server.
- Now go to <extracted_tomcat>/tomcat-7.0.27/webapps/solr-web/WEB-INF/classes/META-INF on Liferay Server.
- Edit solr-spring.xml file and update value of Solr Server IP Address and Port number as mentioned in below example.
<bean id="com.liferay.portal.search.solr.server.BasicAuthSolrServer" class="com.liferay.portal.search.solr.server.BasicAuthSolrServer"> <property name="defaultMaxConnectionsPerRoute" value="20" /> <property name="httpRequestInterceptors"> <list> <bean class="com.liferay.portal.search.solr.interceptor.PreemptiveAuthInterceptor" /> </list> </property> <property name="maxTotalConnections" value="20" /> <property name="url" value="http://[SOLR SERVER IP]:[PORT]/solr" /> </bean>
- After above changes are done, first start the Solr Tomcat Server after start Liferay Tomcat server.
- When Liferay Server starts successfully, follow below steps,
     -> Login with admin user
     -> Go to the Control Panel > Server > Server Administration.
     -> Click on Execute Button beside Reindex all search indexes.