Foren

Customize Search Portlet in Liferay

thumbnail
Parul Seth, geändert vor 15 Jahren.

Customize Search Portlet in Liferay

Junior Member Beiträge: 83 Beitrittsdatum: 18.12.08 Neueste Beiträge
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
Dax Saw, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 165 Beitrittsdatum: 27.03.09 Neueste Beiträge
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
thumbnail
Victor Zorin, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Legend Beiträge: 1228 Beitrittsdatum: 14.04.08 Neueste Beiträge
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:
thumbnail
Denis Signoretto, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Expert Beiträge: 375 Beitrittsdatum: 21.04.09 Neueste Beiträge
Can you attach example source code?
and some more explanation how did you get this results?

Thx.
thumbnail
Victor Zorin, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Legend Beiträge: 1228 Beitrittsdatum: 14.04.08 Neueste Beiträge
Hi Denis, if you are into customised search development, th ebest places to start with is:
- html\portlet\search\search.jsp
- WEB-INF/liferay-portlet.xml, look for tag <open-search-class> and find portlet-specific search implementation classes
- then, go to each of these classes and see how they compose the LUCENE query

Something to start with:
* you should be able to make own classes as a cut-and-paste copy from those search classes.
* modify them to suit your requirements
* compile and make a jar library
* place this jar into common directory
* modify liferay-portlet.xml by placing own classes into <open-search-class> instead of original ones
* run the portal
* tune your search procedures to suit requirements
* to make better presentation of search results, make your own jsp class to render those results
Ask further questions, if you encounter problems.

There was another thread related to search customisation.
Jean Rombi, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

New Member Beiträge: 10 Beitrittsdatum: 01.12.09 Neueste Beiträge
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 ?
thumbnail
Victor Zorin, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Legend Beiträge: 1228 Beitrittsdatum: 14.04.08 Neueste Beiträge
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.
siddhant jain, geändert vor 11 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 69 Beitrittsdatum: 19.03.13 Neueste Beiträge
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
thumbnail
Victor Zorin, geändert vor 11 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Legend Beiträge: 1228 Beitrittsdatum: 14.04.08 Neueste Beiträge
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.
thumbnail
Sagar A Vyas, geändert vor 13 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste Beiträge
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
Katja Korhonen, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

New Member Beitrag: 1 Beitrittsdatum: 14.04.09 Neueste Beiträge
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
thumbnail
Parul Seth, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 83 Beitrittsdatum: 18.12.08 Neueste Beiträge
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
thumbnail
Victor Zorin, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Legend Beiträge: 1228 Beitrittsdatum: 14.04.08 Neueste Beiträge
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
contextQuery.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.
thumbnail
Parul Seth, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 83 Beitrittsdatum: 18.12.08 Neueste Beiträge
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
thumbnail
Victor Zorin, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Legend Beiträge: 1228 Beitrittsdatum: 14.04.08 Neueste Beiträge
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.
V Rao, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 47 Beitrittsdatum: 08.02.08 Neueste Beiträge
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?
thumbnail
Parul Seth, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 83 Beitrittsdatum: 18.12.08 Neueste Beiträge
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:

Portlet portlet = PortletLocalServiceUtil.getPortletById(<companyid>, <portletid>);</portletid></companyid>


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, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 47 Beitrittsdatum: 08.02.08 Neueste Beiträge
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:

Portlet portlet = PortletLocalServiceUtil.getPortletById(<companyid>, <portletid>);</portletid></companyid>


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
thumbnail
Parul Seth, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 83 Beitrittsdatum: 18.12.08 Neueste Beiträge
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

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




Hope that helps emoticon

Thanks & Regards
Parul Seth
V Rao, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 47 Beitrittsdatum: 08.02.08 Neueste Beiträge
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

Portlet 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.
thumbnail
Archi Madhu, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
Hi All,

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


<portlet>
		<portlet-name>intranet-search</portlet-name>
		<icon>/html/icons/search.png</icon>
		<struts-path>intranet_search</struts-path>		
		<open-search-class>
                 com.my.intranet.portal.search.IntranetPortalOpenSearchImpl
                </open-search-class>
		<use-default-template>false</use-default-template>
		<restore-current-view>false</restore-current-view>
		<instanceable>false</instanceable>
		<add-default-resource>true</add-default-resource>
</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, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 192 Beitrittsdatum: 18.11.06 Neueste Beiträge
Please post your default.xml from resource-actions. I think the problem may be the same one I ran into before.
thumbnail
Archi Madhu, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
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?
atul patel, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 192 Beitrittsdatum: 18.11.06 Neueste Beiträge
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
thumbnail
Archi Madhu, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
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

	<portlet>
		<portlet-name>intranet-search</portlet-name>
		<display-name>Intranet Search</display-name>
		<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
		<init-param>
			<name>view-action</name>
			<value>/intranet_search/view</value>
		</init-param>
		<expiration-cache>0</expiration-cache>
		<portlet-info>
			<title>Intranet Search Portlet</title>
			<short-title>Intranet Search Portlet</short-title>
			<keywords>Intranet Search Portlet</keywords>
		</portlet-info>
		<supports>
			<mime-type>text/html</mime-type>
		</supports>
		<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
		<security-role-ref>
			<role-name>guest</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>power-user</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>user</role-name>
		</security-role-ref>
	</portlet>


portlet-ext.xml
	<portlet>
		<portlet-name>intranet-search</portlet-name>
		<icon>/html/icons/search.png</icon>
		<struts-path>intranet_search</struts-path>		
		<open-search-class>
                 com.my.intranet.portal.search.IntranetPortalOpenSearchImpl
                </open-search-class>
		<use-default-template>false</use-default-template>
		<restore-current-view>false</restore-current-view>
		<instanceable>false</instanceable>
		<add-default-resource>true</add-default-resource>
		</portlet>


Can anyone please throw some light on this?

Thanks,
Archi
Lakshminarayana Mummanedi, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

New Member Beiträge: 20 Beitrittsdatum: 30.07.09 Neueste Beiträge
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..
thumbnail
Nagendra Kumar Busam, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Liferay Master Beiträge: 678 Beitrittsdatum: 07.07.09 Neueste Beiträge
Hi Archi,

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

<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
thumbnail
Archi Madhu, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
Yes I did same thing
thumbnail
Archi Madhu, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
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, geändert vor 14 Jahren.

RE: Customize Search Portlet in Liferay

New Member Beiträge: 4 Beitrittsdatum: 05.03.10 Neueste Beiträge
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?
thumbnail
sepideh t, geändert vor 12 Jahren.

RE: Customize Search Portlet in Liferay

Junior Member Beiträge: 32 Beitrittsdatum: 30.10.11 Neueste Beiträge
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?
thumbnail
Namrata Hangal, geändert vor 11 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 161 Beitrittsdatum: 27.07.10 Neueste Beiträge
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?
thumbnail
Praveen P, geändert vor 11 Jahren.

RE: Customize Search Portlet in Liferay

Regular Member Beiträge: 100 Beitrittsdatum: 21.02.12 Neueste Beiträge
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
thumbnail
Vivek Sharma, geändert vor 9 Jahren.

RE: Customize Search Portlet in Liferay

New Member Beiträge: 7 Beitrittsdatum: 28.04.14 Neueste Beiträge
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.