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.

16 comments:

  1. Thank for this post....
    Can you please explain me how we can test integration with search capability.....

    ReplyDelete
    Replies
    1. Hi Sikendar,

      Can you tell me what you want to do ?

      So will give more idea.

      Delete
    2. Hi Vipul,

      I want to integrate solr 5.2.1 with Liferay 6.2. i have gone through these steps as you have given in this post.but i am getting error,since 4.x.x and 5.2.1 directory structure is seems look different.

      Error what i am getting after adding plugin and start the liferay server i am getting below error

      06:26:15,460 ERROR [liferay/search_writer/SYSTEM_ENGINE-1][SolrIndexWriter:100] org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Server at http://localhost:9999/solr/# returned no
      n ok status:405, message:Method Not Allowed
      org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Server at http://localhost:9999/solr/# returned non ok status:405, message:Method Not Allowed

      Delete
    3. Hi Sikendar,

      Yes, because liferay app support solr 4.*.* version.

      Delete
    4. Hi Vipul,

      Thanks for quick response...

      Do you have any search portlet to test on liferay server.

      Thanks,
      Sikendar.

      Delete
    5. Hi Sikendar,

      Please check below link
      http://synapticloop.com/tomes/solr/solr-tutorial/my-first-faceted-example/

      if you get any idea.

      Delete
  2. Caused by: java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.Compiler.(Lorg/eclipse/jdt/internal/compiler/env/INameEnvironment;Lorg/eclipse/jdt/internal/compiler/IErrorHandlingPolicy;Lorg/eclipse/jdt/internal/compiler/impl/CompilerOptions;Lorg/eclipse/jdt/internal/compiler/ICompilerRequestor;Lorg/eclipse/jdt/internal/compiler/IProblemFactory;)V
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:453)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    ... 199 more
    11:40:32,157 ERROR [http-apr-8080-exec-4][render_portlet_jsp:132] null
    java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.Compiler.(Lorg/eclipse/jdt/internal/compiler/env/INameEnvironment;Lorg/eclipse/jdt/internal/compiler/IErrorHandlingPolicy;Lorg/eclipse/jdt/internal/compiler/impl/CompilerOptions;Lorg/eclipse/jdt/internal/compiler/ICompilerRequestor;Lorg/eclipse/jdt/internal/compiler/IProblemFactory;)V
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:453)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
    at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:331)
    at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:128)

    ReplyDelete
  3. i got the above error while following above post

    ReplyDelete
  4. I am using solr-4.3.1 with liferay 6.2. When i create one file or web content. It will index properly but it will reflect after solr core reload only. The current show red after sometime.Initially it green symbol means server active for search.[![enter image description here][1]][1]







    [1]: http://i.stack.imgur.com/Pi7xM.png

    What configuration require so it will remain active all the time. No changes in solrconfig.xml file.

    ReplyDelete
  5. Can you please answer my solr question? http://stackoverflow.com/questions/33496922/solr-liferay-new-data-come-after-reload-only

    ReplyDelete
    Replies
    1. As per my understanding you need to set autocommit in solrconfig.xml.

      Delete
  6. Hi Vipul,

    I am unable to download solr-web-{version}.war file. Can you share its link if you have

    ReplyDelete
    Replies
    1. Hi Chandan,

      Please find below link.
      http://archive.apache.org/dist/lucene/solr/

      thanks

      Delete
    2. Hi Vipul,

      Thanks for your response. But one thing I found like: for lower versions (upto 4.x) war file is there in the downloaded zip.

      From 5.x war files are not found

      Delete