Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Customize Search Portlet in Liferay Parul Seth December 25, 2008 3:41 AM
RE: Customize Search Portlet in Liferay sawi _ May 13, 2009 12:55 AM
RE: Customize Search Portlet in Liferay Victor Zorin May 13, 2009 1:48 AM
RE: Customize Search Portlet in Liferay Denis Signoretto May 20, 2009 9:19 AM
RE: Customize Search Portlet in Liferay Jean Rombi March 23, 2010 5:32 AM
RE: Customize Search Portlet in Liferay Victor Zorin August 30, 2011 2:43 AM
RE: Customize Search Portlet in Liferay siddhant jain April 9, 2013 12:03 AM
RE: Customize Search Portlet in Liferay Victor Zorin April 9, 2013 3:17 PM
RE: Customize Search Portlet in Liferay Sagar A Vyas May 13, 2010 4:38 AM
RE: Customize Search Portlet in Liferay Katja Korhonen May 14, 2009 3:52 AM
RE: Customize Search Portlet in Liferay Parul Seth May 14, 2009 10:27 AM
RE: Customize Search Portlet in Liferay Victor Zorin May 14, 2009 5:38 PM
RE: Customize Search Portlet in Liferay Parul Seth May 18, 2009 12:31 AM
RE: Customize Search Portlet in Liferay Victor Zorin May 18, 2009 1:12 AM
RE: Customize Search Portlet in Liferay V Rao June 11, 2009 11:20 PM
RE: Customize Search Portlet in Liferay Parul Seth June 11, 2009 11:50 PM
RE: Customize Search Portlet in Liferay V Rao June 12, 2009 12:34 AM
RE: Customize Search Portlet in Liferay Parul Seth June 12, 2009 2:31 AM
RE: Customize Search Portlet in Liferay V Rao June 15, 2009 8:04 PM
RE: Customize Search Portlet in Liferay Archi Madhu January 27, 2010 10:43 PM
RE: Customize Search Portlet in Liferay atul patel January 28, 2010 12:42 AM
RE: Customize Search Portlet in Liferay Archi Madhu January 28, 2010 3:06 AM
RE: Customize Search Portlet in Liferay atul patel January 28, 2010 3:20 AM
RE: Customize Search Portlet in Liferay Archi Madhu January 28, 2010 10:45 AM
RE: Customize Search Portlet in Liferay Lakshminarayana Mummanedi February 3, 2010 10:21 AM
RE: Customize Search Portlet in Liferay Nagendra Kumar Busam February 4, 2010 4:20 AM
RE: Customize Search Portlet in Liferay Archi Madhu February 4, 2010 4:58 AM
RE: Customize Search Portlet in Liferay Archi Madhu February 6, 2010 9:44 AM
RE: Customize Search Portlet in Liferay Luca Andreatta March 5, 2010 8:43 AM
RE: Customize Search Portlet in Liferay sepideh tajeri October 30, 2011 4:13 AM
RE: Customize Search Portlet in Liferay Namrata Hangal July 9, 2012 2:13 AM
RE: Customize Search Portlet in Liferay Praveen P July 9, 2012 4:49 AM
RE: Customize Search Portlet in Liferay Vivek Sharma May 6, 2014 11:56 PM
Parul Seth
Customize Search Portlet in Liferay
December 25, 2008 3:41 AM
Answer

Parul Seth

Rank: Junior Member

Posts: 83

Join Date: December 18, 2008

Recent Posts

Hi All

I want to customize the search portlet available in liferay.

Currently the search portlet searches and returns results from the whole portal database (though all if it cannot be accessed).

But I want to restrict this search to a particular community "have a community based search "as in "Search and show only the data (blogs, message boards, users, etc ) within and of a particular community". This will possibly be done by limiting the search by "groupId".

I can easily restrict search by groupId for a search within a single portlet (as is done in the Blog portlets search) but how to do this for searching the data from all the portlets by a single search portlet????


Kindly help me in this regard emoticon.

Thanks & Regards

Parul Seth
sawi _
RE: Customize Search Portlet in Liferay
May 13, 2009 12:55 AM
Answer

sawi _

Rank: Regular Member

Posts: 147

Join Date: March 27, 2009

Recent Posts

hi all
I want to costumize Search Portlet in Liferay,
I need Search and show only the data which i need (for exaple only blog and wiki).

anybody can give me any solution?

Thanks for help
Victor Zorin
RE: Customize Search Portlet in Liferay
May 13, 2009 1:48 AM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

If you download liferay source, there is plenty of code there to help you to develop search solution that fits your own requirements, and especially around security and membership in communities and orgs.
As far as I am aware, many developers have made their own search portlets. I have attached a couple of sample images below:
Attachment

Attachment

Attachment

Attachments: myoffice-global-search-all.gif (38.2k), myoffice-global-search-erms.gif (12.8k), myoffice-global-search-web.gif (40.6k)
Katja Korhonen
RE: Customize Search Portlet in Liferay
May 14, 2009 3:52 AM
Answer

Katja Korhonen

Rank: New Member

Posts: 1

Join Date: April 13, 2009

Recent Posts

Dear Parul,

I am experiencing the exact same problem what you have described! Did you find a solution to this, I would very very very much appreciate to hear from you!

Thanks in advance.

Best regards
Katja
Parul Seth
RE: Customize Search Portlet in Liferay
May 14, 2009 10:27 AM
Answer

Parul Seth

Rank: Junior Member

Posts: 83

Join Date: December 18, 2008

Recent Posts

Hi Katja, Dax

yes I did find a solution to my problem emoticon

And the solution involves just three simple steps for you to follow:

1. go to liferay-portlet.xml search for "<!--<open-search-class>com.liferay.portal.search.PortalOpenSearchImpl</open-search-class>-->"and uncomment the same. One more thing following what you just did will make your search a consolidated one. You need to comment out the default open search classes like you can comment "<open-search-class>com.liferay.portlet.blogs.util.BlogsOpenSearchImpl</open-search-class> " and so on.

2. Then go to the com.liferay.portal.search.PortalOpenSearchImpl class and check if the current groupId (you can get this from themeDisplay.getScopeGroupId()) matches the result's groupId (which is already there in the class) then show entries of the current group only.

3. To only show results from the portlets added in your community you can customize the search.jsp

replace the default code for getting the list of portlets by the below code:

LayoutTypePortlet layoutTypePortlet2 = (LayoutTypePortletImpl)layout.getLayoutType();
List portlets = layoutTypePortlet2.getPortlets();

This gave me the portlets which have been added in the current layout or more specifically the once in the current community.

and BINGO this did the job for me!

I hope this helps you both too and all those who face such a requirement in future emoticon

Take Care
Thanks & Regards
Parul Seth

"Human knowledge belongs to the world"




Katja Korhonen:
Dear Parul,

I am experiencing the exact same problem what you have described! Did you find a solution to this, I would very very very much appreciate to hear from you!

Thanks in advance.

Best regards
Katja
Victor Zorin
RE: Customize Search Portlet in Liferay
May 14, 2009 5:38 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

Small comment on item 2: it may produce discrepancies between the total number of hits and actual items on display list. This is because the search is conducted based on companyId (all groupIds) but when result list gets displayed, all items are dropped out except those matching scopeGroupId.

To avoid users complaints, it would probably be good to remove 'total count' value from the search result screen and limit paging to first/next/previous.

If search is conducted for a specific groupId, the ultimate solution would be to extend lucene query with
1contextQuery.addRequiredTerm(Field.GROUP_ID, scopeGroupId);
It will limit search by required group. If you have a lot of data in all groups and little data in current community, searh still will be fast and results exact.

In our implementations we do search based on user membership, or current scope. Unfortunately, software patches had to be delivered across entire range of classes, so the decision was made to implement own portlet.
Parul Seth
RE: Customize Search Portlet in Liferay
May 18, 2009 12:31 AM
Answer

Parul Seth

Rank: Junior Member

Posts: 83

Join Date: December 18, 2008

Recent Posts

Thanks Victor emoticon that was a good update on item 2 emoticon. Yes, looking at your requirements, implementing a new portlet was a good decision.

Adding to the above three points it will be a good idea to customize the jsp for search portlet extensively as one can very well do so for showing the results as per requirements emoticon
Victor Zorin
RE: Customize Search Portlet in Liferay
May 18, 2009 1:12 AM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

I agree, it would be really good to add configuration to an existing search portlet as per your requirements. I hope Bruno Farache will read this thread, I think he is looking after search implementations.
Denis Signoretto
RE: Customize Search Portlet in Liferay
May 20, 2009 9:19 AM
Answer

Denis Signoretto

Rank: Regular Member

Posts: 204

Join Date: April 21, 2009

Recent Posts

Can you attach example source code?
and some more explanation how did you get this results?

Thx.
V Rao
RE: Customize Search Portlet in Liferay
June 11, 2009 11:20 PM
Answer

V Rao

Rank: Junior Member

Posts: 47

Join Date: February 8, 2008

Recent Posts

Parul Seth:
Hi Katja, Dax

yes I did find a solution to my problem emoticon

And the solution involves just three simple steps for you to follow:

1. go to liferay-portlet.xml search for "<!--<open-search-class>com.liferay.portal.search.PortalOpenSearchImpl</open-search-class>-->"and uncomment the same. One more thing following what you just did will make your search a consolidated one. You need to comment out the default open search classes like you can comment "<open-search-class>com.liferay.portlet.blogs.util.BlogsOpenSearchImpl</open-search-class> " and so on.

2. Then go to the com.liferay.portal.search.PortalOpenSearchImpl class and check if the current groupId (you can get this from themeDisplay.getScopeGroupId()) matches the result's groupId (which is already there in the class) then show entries of the current group only.

3. To only show results from the portlets added in your community you can customize the search.jsp

replace the default code for getting the list of portlets by the below code:

LayoutTypePortlet layoutTypePortlet2 = (LayoutTypePortletImpl)layout.getLayoutType();
List portlets = layoutTypePortlet2.getPortlets();

This gave me the portlets which have been added in the current layout or more specifically the once in the current community.

and BINGO this did the job for me!

I hope this helps you both too and all those who face such a requirement in future emoticon

Take Care
Thanks & Regards
Parul Seth

"Human knowledge belongs to the world"




Katja Korhonen:
Dear Parul,

I am experiencing the exact same problem what you have described! Did you find a solution to this, I would very very very much appreciate to hear from you!

Thanks in advance.

Best regards
Katja


Regarding 3, is there similar code to fetch a single portlet (Eg: wiki portlet only) for search?
Parul Seth
RE: Customize Search Portlet in Liferay
June 11, 2009 11:50 PM
Answer

Parul Seth

Rank: Junior Member

Posts: 83

Join Date: December 18, 2008

Recent Posts

Hi V Rao,

Yupp, you can do that simply by fetching the portlet object for that particular portlet by using the available methods like for instance:

1Portlet portlet = PortletLocalServiceUtil.getPortletById(<companyId>, <portletId>);


or you can comment out other open search classes in liferay-portlet.xml . This is definitely not a good solution tough emoticon. Try the first one.

Hope that helps emoticon

Thanks & Regards
Parul Seth
V Rao
RE: Customize Search Portlet in Liferay
June 12, 2009 12:34 AM
Answer

V Rao

Rank: Junior Member

Posts: 47

Join Date: February 8, 2008

Recent Posts

Parul Seth:
Hi V Rao,

Yupp, you can do that simply by fetching the portlet object for that particular portlet by using the available methods like for instance:

1Portlet portlet = PortletLocalServiceUtil.getPortletById(<companyId>, <portletId>);


or you can comment out other open search classes in liferay-portlet.xml . This is definitely not a good solution tough emoticon. Try the first one.

Hope that helps emoticon

Thanks & Regards
Parul Seth


Thanks. What else would I need to change? I want to restrict results to the directory portlet (portlet id 11)

This is what I have done :

----
while (itr.hasNext()) {
// Portlet portlet = (Portlet)itr.next();

int pid=11;
String portletId = Integer.toString(pid);
Portlet portlet = PortletLocalServiceUtil.getPortletById(company.getCompanyId(), portletId);
-----

That seems to result in an endless while loop and the portlet never loads. I could completely delete the while loop and just delcare the portlet, but search.jsp seems to reference 'portlets' elsewhere

Later on in the code, I find this :

---
for (int i = 0; i < portlets.size(); i++) {
Portlet portlet = (Portlet)portlets.get(i);
--

Thanks in advance,

V
Parul Seth
RE: Customize Search Portlet in Liferay
June 12, 2009 2:31 AM
Answer

Parul Seth

Rank: Junior Member

Posts: 83

Join Date: December 18, 2008

Recent Posts

Hi V Rao

Well the "portlets" is the list of portlets being fetched from the original code in search.jsp. What you now have is a single portlet, you can simply use that, you don't need any loops. The basic requirement for portlet obj is to get the open search class instance, which you can easily get for the portlet of your choice, just have a closer look at the jsp code, you'll get what you want simply by customizing it emoticon

Also you need to add the portlet id as I mentioned, you can use com.liferay.portal.util.PortletKeys for the same, like for blogs

1Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), PortletKeys.BLOGS);




Hope that helps emoticon

Thanks & Regards
Parul Seth
V Rao
RE: Customize Search Portlet in Liferay
June 15, 2009 8:04 PM
Answer

V Rao

Rank: Junior Member

Posts: 47

Join Date: February 8, 2008

Recent Posts

Parul Seth:
Hi V Rao

Well the "portlets" is the list of portlets being fetched from the original code in search.jsp. What you now have is a single portlet, you can simply use that, you don't need any loops. The basic requirement for portlet obj is to get the open search class instance, which you can easily get for the portlet of your choice, just have a closer look at the jsp code, you'll get what you want simply by customizing it emoticon

Also you need to add the portlet id as I mentioned, you can use com.liferay.portal.util.PortletKeys for the same, like for blogs

1Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), PortletKeys.BLOGS);




Hope that helps emoticon

Thanks & Regards
Parul Seth


Thanks. I added the code after the loop and it works fine.
Archi Madhu
RE: Customize Search Portlet in Liferay
January 27, 2010 10:43 PM
Answer

Archi Madhu

Rank: Regular Member

Posts: 238

Join Date: March 24, 2008

Recent Posts

Hi All,

I have to make custom search work, I made a new search portlet for my application.
I changed liferay-portlet-ext.xml

 1
 2<portlet>
 3        <portlet-name>intranet-search</portlet-name>
 4        <icon>/html/icons/search.png</icon>
 5        <struts-path>intranet_search</struts-path>       
 6        <open-search-class>
 7                 com.my.intranet.portal.search.IntranetPortalOpenSearchImpl
 8                </open-search-class>
 9        <use-default-template>false</use-default-template>
10        <restore-current-view>false</restore-current-view>
11        <instanceable>false</instanceable>
12        <add-default-resource>true</add-default-resource
13</portlet>



Where IntranetPortalOpenSearchImpl extends PortalOpenSearchImpl

My problem is when I make search using this portlet I get following error...
even search results are coming fine and portlet works,but I get following error on server side:




06:28:36,906 ERROR [JDBCExceptionReporter:101] Duplicate entry '10115--1' for key 2
06:28:36,953 ERROR [SearchPermissionCheckerImpl:110] com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: Could not execute JDBC batch upd
com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: Could not execute JDBC batch update
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:88)
at com.liferay.portal.service.persistence.ResourceCodePersistenceImpl.updateImpl(ResourceCodePersistenceImpl.java:315)
at com.liferay.portal.service.persistence.ResourceCodePersistenceImpl.update(ResourceCodePersistenceImpl.java:284)
at com.liferay.portal.service.impl.ResourceCodeLocalServiceImpl.addResourceCode(ResourceCodeLocalServiceImpl.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy60.addResourceCode(Unknown Source)
at com.liferay.portal.service.impl.ResourceCodeLocalServiceImpl.getResourceCode(ResourceCodeLocalServiceImpl.java:137)
at sun.reflect.GeneratedMethodAccessor131.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy60.getResourceCode(Unknown Source)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.getResource_1to5(ResourceLocalServiceImpl.java:772)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.getResource(ResourceLocalServiceImpl.java:321)
at sun.reflect.GeneratedMethodAccessor130.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy57.getResource(Unknown Source)
at com.liferay.portal.service.ResourceLocalServiceUtil.getResource(ResourceLocalServiceUtil.java:193)
at com.liferay.portal.search.SearchPermissionCheckerImpl.doGetPermissionQuery_5(SearchPermissionCheckerImpl.java:211)
at com.liferay.portal.search.SearchPermissionCheckerImpl.getPermissionQuery(SearchPermissionCheckerImpl.java:101)
at com.liferay.portal.kernel.search.SearchEngineUtil.search(SearchEngineUtil.java:121)
at com.liferay.portal.service.impl.CompanyLocalServiceImpl.search(CompanyLocalServiceImpl.java:474)
at com.liferay.portal.service.impl.CompanyLocalServiceImpl.search(CompanyLocalServiceImpl.java:430)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy15.search(Unknown Source)
at com.liferay.portal.service.CompanyLocalServiceUtil.search(CompanyLocalServiceUtil.java:187)
at com.dsi.intranet.portal.search.IntranetPortalOpenSearchImpl.search(IntranetPortalOpenSearchImpl.java:61)
at org.apache.jsp.html.portlet.ext.intranetsearch.search_jsp._jspService(search_jsp.java:1596)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)


I searched on forum and found that if I empty data of resourcecode table,It will not give this error again...

this worked for the first time but again Iam getting same error.

Can someone tell me what can be reason of this?

Here in Exception "10115" is my company Id and error tells somrthing about duplicate entries.

Thanks a lot,
Archi
atul patel
RE: Customize Search Portlet in Liferay
January 28, 2010 12:42 AM
Answer

atul patel

Rank: Regular Member

Posts: 190

Join Date: November 17, 2006

Recent Posts

Please post your default.xml from resource-actions. I think the problem may be the same one I ran into before.
Archi Madhu
RE: Customize Search Portlet in Liferay
January 28, 2010 3:06 AM
Answer

Archi Madhu

Rank: Regular Member

Posts: 238

Join Date: March 24, 2008

Recent Posts

Hey ,Thanks for your quick reply!

Here with I have attached it.
Can you please tell me what exactly you are looking for in this?
Attachments: default.xml (1.0k)
atul patel
RE: Customize Search Portlet in Liferay
January 28, 2010 3:20 AM
Answer

atul patel

Rank: Regular Member

Posts: 190

Join Date: November 17, 2006

Recent Posts

Hmm. Looks like you're developing in ext environment.

Maybe its better for me to describe the problem I had and that could help you. We had had developed on custom portlet, and on each deploy we would get a similar error. We had to keep deleting Resource entries.

The issue turned out to be a bug in how liferay parses the resource-actions xml file for the portlet and auto formatting.

here is a little example:

This works:

<model-resource>
<model-name>com.liferay.portlet.journal</model-name>
<portlet-ref>
...

This doesn'w work:
<model-resource>
<model-name>
com.liferay.portlet.journal
</model-name>
<portlet-ref>

The name is used as a key, but its not trimmed. So when determining whether or not to register the portlet it thinks it needs to creates the resource record, but when it does the key is trimmed.

its been a while since I had this problem so I hope I'm relating this issue correctly.

Bottom line, make sure that there aren't any spaces or new lines for model-name or portlet-name

There also was in issue of the model being cached. So you may want to try this:
Bring down liferay.
Delete the related resources entries
Restart liferay

Hope this helps.

Atul
Archi Madhu
RE: Customize Search Portlet in Liferay
January 28, 2010 10:45 AM
Answer

Archi Madhu

Rank: Regular Member

Posts: 238

Join Date: March 24, 2008

Recent Posts

No luck with that.

I made resource_ and resourcecode table empty and restarted server.

but gain when I start server it gives same error.
liferay-portlet-ext.xml
 1
 2    <portlet>
 3        <portlet-name>intranet-search</portlet-name>
 4        <display-name>Intranet Search</display-name>
 5        <portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
 6        <init-param>
 7            <name>view-action</name>
 8            <value>/intranet_search/view</value>
 9        </init-param>
10        <expiration-cache>0</expiration-cache>
11        <portlet-info>
12            <title>Intranet Search Portlet</title>
13            <short-title>Intranet Search Portlet</short-title>
14            <keywords>Intranet Search Portlet</keywords>
15        </portlet-info>
16        <supports>
17            <mime-type>text/html</mime-type>
18        </supports>
19        <resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
20        <security-role-ref>
21            <role-name>guest</role-name>
22        </security-role-ref>
23        <security-role-ref>
24            <role-name>power-user</role-name>
25        </security-role-ref>
26        <security-role-ref>
27            <role-name>user</role-name>
28        </security-role-ref>
29    </portlet>


portlet-ext.xml
 1    <portlet>
 2        <portlet-name>intranet-search</portlet-name>
 3        <icon>/html/icons/search.png</icon>
 4        <struts-path>intranet_search</struts-path>       
 5        <open-search-class>
 6                 com.my.intranet.portal.search.IntranetPortalOpenSearchImpl
 7                </open-search-class>
 8        <use-default-template>false</use-default-template>
 9        <restore-current-view>false</restore-current-view>
10        <instanceable>false</instanceable>
11        <add-default-resource>true</add-default-resource>
12        </portlet>


Can anyone please throw some light on this?

Thanks,
Archi
Lakshminarayana Mummanedi
RE: Customize Search Portlet in Liferay
February 3, 2010 10:21 AM
Answer

Lakshminarayana Mummanedi

Rank: New Member

Posts: 20

Join Date: July 30, 2009

Recent Posts

I am suspecting that you are passing userId as argument for your search, which is making some permission issues.
Can try passing the userId as zero like below for search

Hits results = CompanyLocalServiceUtil.search(themeDisplay.getCompanyId(), userId, keywords,QueryUtil.ALL_POS, QueryUtil.ALL_POS);

Hits results = CompanyLocalServiceUtil.search(themeDisplay.getCompanyId(), 0, keywords,QueryUtil.ALL_POS, QueryUtil.ALL_POS);

Hope this will help you..
Nagendra Kumar Busam
RE: Customize Search Portlet in Liferay
February 4, 2010 4:20 AM
Answer

Nagendra Kumar Busam

Rank: Liferay Master

Posts: 598

Join Date: July 7, 2009

Recent Posts

Hi Archi,

Did you try by changing portlet-ext.xml as below (without spaces before & after fully qualified classaname)

1<open-search-class>com.my.intranet.portal.search.IntranetPortalOpenSearchImpl</open-search-class>


I am not that much sure it will work or not, just try it once. Let us know if it is working or not

Thanks & Regards,
- Nagendra Kumar
Archi Madhu
RE: Customize Search Portlet in Liferay
February 4, 2010 4:58 AM
Answer

Archi Madhu

Rank: Regular Member

Posts: 238

Join Date: March 24, 2008

Recent Posts

Yes I did same thing
Archi Madhu
RE: Customize Search Portlet in Liferay
February 6, 2010 9:44 AM
Answer

Archi Madhu

Rank: Regular Member

Posts: 238

Join Date: March 24, 2008

Recent Posts

Yes...what lakshminarayana suggested works fine for me

Hits results = CompanyLocalServiceUtil.search(themeDisplay.getCompanyId(), userId, keywords,QueryUtil.ALL_POS, QueryUtil.ALL_POS);

If I pass userId as 0 its no more giving exception to me!

Thanks!
Luca Andreatta
RE: Customize Search Portlet in Liferay
March 5, 2010 8:43 AM
Answer

Luca Andreatta

Rank: New Member

Posts: 4

Join Date: March 5, 2010

Recent Posts

Hi archi,
I have the same problem in my search portlet.

Your solution doesn't work for me because your fix will show me all results also if I don't have permission to view them.

Isn't it a problem for you?

Is there any way to solve it?

I'm using Liferay 5.2.3.

While debugging i found that the error is caused because Liferay try to insert in DB two or more ResourceCode objects with the name = null. In CompanyLocalServiceImpl, in the search method, the call to SearchEngineUtil.search(companyId, groupId, userId, null, fullQuery, start, end); is made passing null for the parameter className.

I don't understand why, but it seems like a bug to me.

Can anyone help me?
Jean Rombi
RE: Customize Search Portlet in Liferay
March 23, 2010 5:32 AM
Answer

Jean Rombi

Rank: New Member

Posts: 10

Join Date: December 1, 2009

Recent Posts

Victor Zorin:
If you download liferay source, there is plenty of code there to help you to develop search solution that fits your own requirements, and especially around security and membership in communities and orgs.
As far as I am aware, many developers have made their own search portlets. I have attached a couple of sample images below:


Are you sure this is a portlet ? (it could be Liferay Social Office...)
I didn't find this example in liferay-portal-src-5.2.3....
Where are these sources ?
Victor Zorin
RE: Customize Search Portlet in Liferay
August 30, 2011 2:43 AM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

No, these screen dumps are for own search portlet, because CE version (in version of up to 5.2.3) was 'a bit' non-user friendly. EE search portlet looks better, but still lacks cross-community search. Not sure what is in LR6.
Look into liferay source code and see how it delivers results, then make your custom layout if need one. In our case we had to extend search beyond Liferay data, such as going into Lotus Domino assets as well as into corporate directories without forcing massive import of files into liferay document libraries, see http://www.myoffice24x7.com/web/mysearch-portlet.
Sagar A Vyas
RE: Customize Search Portlet in Liferay
May 13, 2010 4:38 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 655

Join Date: April 17, 2009

Recent Posts

Hi Dariusz,

You need to modify search.jsp located on (\tomcat\webapps\ROOT\html\portlet\search\search.jsp),

Liferay by default search searching from 9 portlets...

you can restrict with condition like below..

lets say you want search from journal article only then you can go for following stuff

if (portlet.getPortletId().equals(PortletKeys.JOURNAL))
{

.......your stuff.....

}



Thanks and Regards,
Sagar Vyas
sepideh tajeri
RE: Customize Search Portlet in Liferay
October 30, 2011 4:13 AM
Answer

sepideh tajeri

Rank: Junior Member

Posts: 32

Join Date: October 30, 2011

Recent Posts

Hi All
I'm using liferay 5.2.3.
I want use a custom search that it search some items. I don't know that what do I do?
Can you help me?
Namrata Hangal
RE: Customize Search Portlet in Liferay
July 9, 2012 2:13 AM
Answer

Namrata Hangal

Rank: Regular Member

Posts: 161

Join Date: July 26, 2010

Recent Posts

I'm looking to connect Nutch+Solr with Liferay. I don't think I can use the search portlet out of the box for this requirement. I need results from Nutch-crawled data (external website) and Liferay content (blogs, wiki, etc.).

Where do I begin?
Praveen P
RE: Customize Search Portlet in Liferay
July 9, 2012 4:49 AM
Answer

Praveen P

Rank: Regular Member

Posts: 100

Join Date: February 20, 2012

Recent Posts

Hi, to add search function in custom portlet please go through this post
http://www.liferay.com/community/forums/-/message_boards/message/4878831

It may help you, but i have achieved using connection statement as like jdbc
siddhant jain
RE: Customize Search Portlet in Liferay
April 9, 2013 12:03 AM
Answer

siddhant jain

Rank: Junior Member

Posts: 45

Join Date: March 19, 2013

Recent Posts

hi victor
i am new to liferay and i have one query that can we have advanced search options in liferay .for eg see the link :

advanced search

i want to restrict the search based on the conditions specified (same as in link)

i am using liferay6.0.6

if it is not possible in default search in liferay then can you suggest any third party search tool that can provide me these facilities??

please help!!! ASAP emoticon
Victor Zorin
RE: Customize Search Portlet in Liferay
April 9, 2013 3:17 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1174

Join Date: April 14, 2008

Recent Posts

Most of those search requirements can be achieved via customization of underlying queries, not sure if that can be achieved ASAP in your environment.

I am not aware about any 3rd party portlets that do exactly what you need, in some of our installations we simply provided an additional help material of how to write the query within the single search field, instead of having multiple search fields such as 'match exactly', 'any of words', etc. That was on own search portlet, in the past Liferay OOTB search portlet has never achieved what customer required.
If you need exactly what's on google, you would need to do a custom development.
Vivek Sharma
RE: Customize Search Portlet in Liferay
May 6, 2014 11:56 PM
Answer

Vivek Sharma

Rank: New Member

Posts: 7

Join Date: April 28, 2014

Recent Posts

Hi Parul,

I am new to Liferay. And i want some help in customizing the Search Portlet. I have few questions for you if you can please help me out.

1. Can i create my own New Search Portlet and override the functionality of the liferay Search Portlet through a hook ..??

2. If overriding is not possible So, can i customize the Liferay Search Portlet..?

3.I want to customize the search in a way that it searches the Liferay portal for a query and also i want to add some external Data Sources which i want to search and fetch results and display. Can i do that..?? if Yes.. How can i do that.

Please help me out and explain me the steps to do that. I will be really thankful to you.

Regards,
Vivek Sharma.