Tuesday, October 29, 2013

solr configuration problem with Liferay 6.0

Dear friends,

In this post I am writing the solution for solr exception, usually it happens when you configure solr with Liferay portal. Especially if you are using same tomcat(Liferay's tomcat) bundle for solr.

I think you may facing the problem like, not able to delete pages after configuring solr engine with you portal.You may get exceptions like as fallows.

14:40:42,293 ERROR [SolrIndexSearcherImpl:75] org.apache.solr.client.solrj.SolrServerException: Error executing query
org.apache.solr.client.solrj.SolrServerException: Error executing query
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:95)

4:40:42,294 ERROR [SearchReaderMessageListener:34] Unable to process message {destinationName=liferay/search_reader, responseDestinationName=liferay/search_reader/response, responseId=93563af8-e4ba-4e88-9bbe-5028898b79ef, payload={companyId=10132, document=null, documents=null, end=-1, id=null, ids=null, query=+portletId:19 +threadId:20706, searchEngineCommand=SEARCH, sorts=[{fieldName=null, type=0, reverse=false}, {fieldName=modified, type=6, reverse=true}], start=-1}, values=null}
com.liferay.portal.kernel.search.SearchException: Error executing query
at com.liferay.portal.search.solr.SolrIndexSearcherImpl.search(SolrIndexSearcherImpl.java:77)
at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.doCommandSearch(SearchReaderMessageListener.java:41)
at com.liferay.portal.kernel.search.messaging.SearchReaderMessageListener.doReceive(SearchReaderMess

For this root cause is, solr is recommended to configure in separate tomcat. Still its not a problem if you have configured with liferay server. But you need to add two important things as mentioned below.

1. Add the fallowing line in schema.xml of solr and index you are trying to access
          <field name="modified" type="text" indexed="true" stored="true" />  
2. Change the SolrIndexSearchImpl.java class add fallowing code with class method "subset" replacing the original code  i,e
         
                 for (String name : names) {
                                    Field field = new Field(
                                    name, solrDocument.getFieldValue(name).toString(), false);
                                   document.add(field);
                                                      }


 replace above code with fallowing code

           for (String name : names) {  
                           Field field = new Field(name,  
                          ArrayUtil.toStringArray(solrDocument.getFieldValues(name).toArray()), false); 
                          document.add(field);  
                                                  } 
I hope it may help somebody. 

Thanks Guys,

No comments:

Post a Comment