Configure solr 4.0 with Liferay 6.1.2 EE

PART 1: SETTING UP SOLR with TOMCAT

Step 1: Download Solr. It's just a zip file.

Step 2: Copy from your SOLR_HOME_DIR/dist/apache-solr-1.3.0.war to your tomcat webapps directory: $CATALINA_HOME/webapps/solr.war – Note the war file name change. That’s important.

Step 3: Create your solr home directory at a location of your choosing. This is where the configuration for that solr install resides. The easiest way to do this is to copy the SOLR_HOME_DIR/examples/solr directory to wherever it is you want your solr home container to be. Say place it in C:\solr.

Step 4: Hope you have set your environment variables, if not then please set JAVA_HOME, JRE_HOME, CATALINA_OPTS, CATALINA_HOME. Note that CATALINA_HOME refers to your Tomcat directory & CATALINA_OPTS refers to the amount of heap memory you want to give to your Solr.

Step 5: Start tomcat. Note this is only necessary to allow tomcat to unpack your war file. If you look under $CATALINA_HOME/webapps there should now be a solr directory.

Step 6: Stop tomcat

Step 7: Go into that solr directory and edit WEB-INF/web.xml. Scroll down until you see an entry that looks like this:

<!-- People who want to hardcode their "Solr Home" directly into the
     WAR File can set the JNDI property here...
 -->
<!--
  <env-entry>
     <env-entry-name>solr/home</env-entry-name>
     <env-entry-value>/Path/To/My/solr/Home/solr/</env-entry-value>
     <env-entry-type>java.lang.String</env-entry-type>
  </env-entry>
-->

Set your Solr home (for example: C:\solr) and uncomment the env entry.

Step 8: Start Tomcat again, and things should be going splendidly. You should be able to verify that solr is running by trying the url http://localhost:8080/solr/admin/.




PART 2: CONFIGURE SOLR PLUGIN ON LIFERAY

    Once the Solr instance is set, install the Solr plug-in in the portal. How does it work? The following is a sample which could bring the plugin Solr into the portal.

Step 1:    Download required WAR file ${solr.web.war}.  

Step 2:    Drop the WAR file ${solr.web.war} to the folder $LIFERAY_HOME/deploy when the portal is running

           After deploying successfully, you should shut down the portal and Solr instance, and moreover, configure the Solr instance with the Solr plugin as follows.

Step 3:    Open $AS_WEB_APP_HOME/solr-web/WEB-INF/classes/META-INF/solr-spring.xml and update Solr instance settings as follows

            <bean id=”solrServer”     class=”com.liferay.portal.search.solr.server.BasicAuthSolrServer”>
            <constructor-arg type=”java.lang.String” value=” http://${solr.host.domain}:$    {solr.port.number}/solr” />
            </bean>

            <bean id="com.liferay.portal.search.solr.SolrSearchEngineImpl"

            class="com.liferay.portal.kernel.search.BaseSearchEngine">

            <property name="clusteredWrite" value="false" />

            <property name="indexSearcher"

            ref="com.liferay.portal.search.solr.SolrIndexSearcherImpl" />

            <property name="indexWriter" ref="com.liferay.portal.search.solr.SolrIndexWriterImpl" />

            <property name="luceneBased" value="true" />

            <property name="vendor" value="SOLR" />

            </bean>

        

            <!-- Configurator -->

            

            <bean id="searchEngineConfigurator.solr"

            class="com.liferay.portal.kernel.search.PluginSearchEngineConfigurator">

            <property name="searchEngines">

            <map key-type="java.lang.String" value-

            type="com.liferay.portal.kernel.search.SearchEngine">

            <entry key="SYSTEM_ENGINE_ID">

            <ref bean="com.liferay.portal.search.solr.SolrSearchEngineImpl" />

            </entry>

            </map>

            </property>

            <property name="defaultSearchEngineId" value="SYSTEM_ENGINE_ID" />

            </bean>

Step 4:    Drop the schema file schema.xml from $AS_WEB_APP_HOME/solr-web/WEB-INF/conf to $SOLR_HOME/example/solr/conf in the domain ${solr.host.domain} – replacing the exiting the schema file schema.xml; and restart Solr instance and the portal

Blogs
Hi,
i'm trying to configure Solr 4.3.1 with liferay6.1.1-ce-ga2.
I would like to know if this tutorial is working for versions above.
I follow yours step until step 8.
By entering the url http://localhost:8080/solr/admin , it returns the message:
"Not Found"
The requested resource was not found.
http://localhost:8080/solr/admin

Waiting yours
Paolo
Hi ,

For solr server config u need a standalone tomcate server which is differ then liferay tomcate server , first check your tomcate is working , localhost:8080 and then download solr and follow step.
SOLR 4.3 no longer uses the default core option. I had to make sure that on teh solr-soring.xml I configured the url as http://host:port/solr/[collection-name] .. for example

http://localhost:8080/solr/collection1 or in my case http://localhost:8088/solr/liferay

This allowed the ping to work correctly as it hits /solr/[collection]/admin/ping instead of the 404 /solr/admin/ping
Paolo,

Were you able to get this to work with SOLR 4.3.1?

Thanks,
Adam
Hi Priti,
Please could you let me know how one can we get EE version of solr-web plugin compatible with Liferay 6.1.2 EE and Solr 4 ?
do we need two different tomcat server for solr and liferay?
because i followed the steps you mentioned but i am gettting message ass
"Not Found"
The requested resource was not found.
http://localhost:8080/solr/admin
Hi Mahesh ,

Yes we required two different tomcat server for solr config.
If the Solr instance is running on a different port, say 8983, you also have to change it in the $APP_SERVER_HOME\webapps\solr-web\WEB-INF\classes\META-INF\solr-spring.xml.

Also, Solr 4.6 would not start cleanly without these fields in the
$SOLR_HOME\example\solr\collection1\conf\schema.xml
------------------------------------------------------------------------------------------------
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="false"/>
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
-----------------------------------------------------------------------------------------------

I placed the above values in schema.xml of $AS_WEB_APP_HOME/solr-web/WEB-INF/conf & then copied the schema.xml to $SOLR_HOME/example/solr/collection1/conf in the domain ${solr.host.domain} .
NOTE the collection1 under $SOLR_HOME/example/solr/collection1
Then restart the Solr 4.6 server, followed by Liferay 6.1, and Viola!
hi,

Can you please guide how to connect solr4.4 from liferay 6.2 spring portlet

I have written following code for it
SolrServer server = new LBHttpSolrServer("http://localhost:8983/solr/");
SolrQuery query = new SolrQuery();
query.setQuery("coins");
QueryResponse res = server.query(query);

but for above QueryResponse it shows following exception
05:40:26,920 ERROR [http-bio-8080-exec-16][render_portlet_jsp:132] null
java.lang.NoSuchMethodError: org.apache.http.impl.conn.SchemeRegistryFactory.createSystemDefault()Lorg/apache/http/conn/scheme/SchemeRegistry;
at org.apache.http.impl.client.SystemDefaultHttpClient.createClientConnectionManager(SystemDefaultHttpClient.java:118)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:445)
at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:274)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:797)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:365)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180)
at org.apache.solr.client.solrj.impl.LBHttpSolrServer.request(LBHttpSolrServer.java:446)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
at com.tru.portal.registry.search.controller.SearchController.defaultSearch(SearchController.java:65)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)


can you please provide solution for above issue.

Thanks,
Sneha
Hi Sneha,

configuration steps are same,only diff is you need to use latest solr web plugin for liferay 6.2.
I have solr instance separately and connecting to solr with the above code and getting the NoSuchMethodError. I am not deploying the solr plugin. Can you help on this?
Hi Priti,

Thanks for this wonderful blog. It really help a lot.
I see many comments people asking for Apache solr 4.1+ configuration with liferay 6.1.

It was little confusing from the title solr 4.0 with liferay, which indirectly configuring apache solr 1.3 or apache solr 1.4 version with liferay 6.1 Version.

In order to configure actual Apache solr 4.0+ version with liferay which is not supported at this point with liferay 6.1 version. But If you want to make it supportive , need to modify the code in solr web plugin.

For more info, refer this forum..
https://www.liferay.com/community/forums/-/message_boards/view_message/28166099

Thanks,
Amit Doshi