Federated search is the simultaneous search of multiple online databases or web resources, and it is an emerging feature of automated, web-based library and information retrieval systems. Here federated search is referred to the portal.
It is very useful to provide federated search abilities, such as search for Blogs entries, users, organizations, Calendar entries, Bookmarks entries, Document Library documents, Image Gallery images, Message Boards message, Wiki articles, Web Content articles, Directory, etc. The portal has provides a set of search portlets. In this section, we’re going to have a deep look on these portlets.
Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)
This article will show you how to customize seach portlet, how to configure it and how to customize the look and feel of the portlet Search.
Search portlet
The Search Portlet (portlet ID 3) is a JSR-286 compliant portlet that can be used for federated search. By default, the portal itself is the search provider.
As shown in following figure, Search Portlet provides a federated search against Blogs entries, users, organizations, Calendar entries, Bookmarks entries, Document Library documents, Image Gallery images, Message Boards message, Wiki articles, Web Content articles, Directory, etc. And moreover, Search Portlet provides a federated search against plugins portlets like Alfresco Content portlet, Knowledge Base portlet.
![]()
Note that when search assets, you would have ability to specify the scope of search results: Everything or This Community. Everything means search results will come from any groups in current portal instance, like communities, organizations, and my community. This Community means search results will come from current group in the portal instance, like community Guest, organization “Palm Tree Enterprise” and My Community.
Above search results would cover Blogs entries, users, organizations, Calendar entries, Bookmarks entries, Document Library documents, Image Gallery images, Message Boards message, Wiki articles, Web Content articles, Directory, etc. And moreover, search results will include assets from plugins portlets like Alfresco Content portlet.
As you can see, search results would be displayed as a title with a link. If you have proper permission on an asset, you could click on the title with a link of the asset and view the asset as well. But if you don’t have proper permission on an asset, you could click on the title with a link of the asset and see permission error message.
What’s happening?
The portal provides many portlets to support OpenSearch framework, like Message Boards, Blogs, Wikis, Directory and Document Library, Users, Organizations, etc. In addition, plugins like Alfresco Content portlet also supports OpenSearch framework as shown in following screenshot. Normally, these portlets have following OpenSearch framework configuration.
<open-search-class>class-name</open-search-class>
The Search portlet obtains an OpenSearch instance from each portlet which has the tag <open-search-class> definition. For example, the portlet Directory (portlet ID 11) allows users to search for other users, organizations or user groups. OpenSearch has been specified for the portlet Directory in $PORTAL_ROOT_HOME/WEB-INF/liferay-portlet.xml as follows.
<open-search-class>com.liferay.portlet.directory.util.DirectoryOpenSearchImpl</open-search-class>
As shown in above code, the open-search-class value must be a class that implements com.liferay.portal.kernel.search.Open-Search, called to get search results in the OpenSearch standard.

Configuration
As mentioned above, OpenSearch in the search portlet cover out-of-out of Blogs, Calendar, Bookmarks, Document Library, Image Gallery, Message Boards, Wiki, Web Content, Directory, etc. Fortunately, the portal adds ability to remove these portlets from the list of portlets searched by the portlet Search as follows.
com.liferay.portlet.blogs.util.BlogsOpenSearchImpl=true
com.liferay.portlet.bookmarks.util.BookmarksOpenSearchImpl=true
com.liferay.portlet.calendar.util.CalendarOpenSearchImpl=true
com.liferay.portlet.directory.util.DirectoryOpenSearchImpl=true
com.liferay.portlet.documentlibrary.util.DLOpenSearchImpl=true
com.liferay.portlet.imagegallery.util.IGOpenSearchImpl=true
com.liferay.portlet.journal.util.JournalOpenSearchImpl=true
com.liferay.portlet.messageboards.util.MBOpenSearchImpl=true
com.liferay.portlet.wiki.util.WikiOpenSearchImpl=true
As shown in above code, you can set any of above properties to false to disable the portlet from being searched by the search portlet in portal-ext.properties.
Above properties should be used for Liferay portal 6.0 or above (or 5.2 EE 5.2.7 SP3 or above).
For 5.2 or below, you can go to $PORTAL_ROOT_HOME/liferay-portlet.xml and comment out OpenSearch.
For more details, you could refer to the book: Liferay Portal 5.2 Systems Development
For example, if you don't want search results from Directory, you could do following.
<!-- <open-search-class>com.liferay.portlet.directory.util.DirectoryOpenSearchImpl</open-search-class> -->
Similarly, you could apply the same on Blogs entries, users, organizations, Calendar entries, Bookmarks entries, Document Library documents, Image Gallery images, Message Boards message, Wiki articles, Web Content articles, and custom portlets like Alfresco Content portlet, Knowledge Base portlet, etc.
Customization
In real cases, you may be required to use the portlet Search in different ways. Anyway, you would be able to customize the portlet Search. Here we’re going to discuss how to use the Search portlet in Social Office and how to use the Search portlet in themes.
The Social Office overrides the UI taglib <liferay-ui:search> in the portlet so-portlet through JSP files hooks in $AS_WEB_APP_HOME/so-portlet/META-INF/custom_jsps/html/taglib/ui/search/start.jsp as follows
<liferay-util:include page="/html/taglib/ui/search/start.portal.jsp" />
<c:if test="<%= group.isUser() %>">
<script type="text/javascript">
var searchOptions = jQuery('select[name=<%= namespace %>groupId] option');
searchOptions.each(
function(i) {
var searchOption = jQuery(this);
if (searchOption.val() != 0) {
searchOption.remove();
}
}
);
</script>
</c:if>
As shown in above code, the social office overrides the look and feel of the portlet Search. For example, it will remove search options.
Of course, you can add the portlet Search in themes as runtime portlet. You could add Velocity template $theme.search() in the theme, specifically in the VM file portal_normal.vm or VM file included in portal_normal.vm. For example, Social Office specified following lines in the theme so-theme, like $AS_WEB_APP_HOME/so-theme/templates/navigation_top.vm.
#if ($is_signed_in)
<div class="my-search">$theme.search()</div>
#end
As shown in above code, when user signed in, the Social Office will show customized portlet Search in a style “my-search”.
For more information about OpenSearch in Liferay portal, you may refer to the book: Liferay Portal Enterprise Intranets.
Acknowledgements
I would like to thank team members at Liferay, especially thanks to Raymond Auge, Brian Chan, Bryan Cheung, Jorge Ferrer, Michael Young, Jerry Niu, Ed Shin, Craig Kaneko, Brian Kim, Bruno Farache, Thiago Moreira, Amos Fong, Scott Lee and David Truong of Liferay for providing the valuable information and all the support. Thanks to friends in Liferay community for providing comments and suggestions.


