ShowTable of Contents
IBM® WebSphere® Portal provides search features out of the box to enable Web site/portal search with very few configuration changes. A search crawler runs in the background collecting and indexing documents configured under the Content Source URL.
But what happens when the content resides in a different system? How do we search the results and display them on the WebSphere Portal UI? How do we make sure that the search content displays based on relevance or any other sorting criteria?
In this article, we discuss an approach to create a custom search that searches IBM Web Content ManagerTM
(WCM), IBM Connections and IBM Lotus® Quickr®.
Figure 1 illustrates the architecture of this solution. The diagram shows how Representational State Transfer (REST) calls are made from a custom search portlet to each of the WCM, Connections and Quickr systems. When a user enters a search query, the search results are fetched from each of these systems concurrently, and the results are combined and sorted by relevance and displayed on the UI.
Figure 1. Solution architecture
As detailed in the architecture diagram above, the portlet resides in WebSphere Portal. We use REST Services provided by each of these applications---WCM, Connections and Quickr---to get our search results and touch upon how we can get the search results from Lotus Quickr for Domino®. In our solution, we assume that single sign-on exists (SSO) between all three systems.
Obtaining results from WCM
To get the search results from WCM, we use the following query:
Upon firing the query, the results are returned in a feed format. The code in listing 1 shows how the feed data can be parsed and the values retrieved. We use the Abdera parser to parse the XML retrieved. We can store the values retrieved from the WCM feed as an Object or an ArrayList.
Listing 1. Code to parse feed retrieved from WCM
Obtaining results from IBM Connections
To get the search results from IBM Connections, we use this query, in which we can specify which components to include for our search results:
Similar to WCM, the code in listing 2 parses the feed retrieved from IBM Connections and stores the result as an object. The relevance obtained from IBM Connections is on a scale of 0 –- 1. We must multiply the relevance by 100 to be consistent with WCM and Lotus Quickr.
Listing 2. Code to parse feed retrieved from IBM Connections
Searching for Employee Profiles from IBM Connections
. The Employee Profile information can be searched separately. For example, a search to find all the intranet employees of an organization starting with the word “John” would display the Employee Photo, Employee Name, Employee Designation, Email, and Phone Number. The format could display as shown in figure 2.
Figure 2. Example Employe Profiles search results
Obtaining results from Quickr for Java
Quickr for JavaTM
. Similar to WCM and Connections, we can retrieve the Quickr results by using the Search REST APIs. We use this link to retrieve search results from the Quickr Server:
http://<host>:<port>/searchfeed/myserver/search?query=Quickr&scope=DYNAMIC_SCOPE.MyFavoritesScopeBrowseFactoryQuickr for Domino.
There are no REST Services available for Quickr for Domino so, to get the results from Lotus Domino, we need to write a servlet on the Quickr Server. This servlet, in turn, calls the QPTOOL utility provided by Quickr Domino and gets us the search results.
From the portlet, we need to pass the User DN while calling the servlet and, to get the USERDN, we use the Portal User Management Architecture (PUMA) Service API. The code in listing 3 helps us to obtain the USERDN.
Listing 3. Code to obtain USERDN
We must provide the search text as an input file, the user information (USERDN) in a session file, and specify an output file name. The output file contains the results we obtain by running the QPTOOL utility, and it must be parsed by use of XML Parser utilities and the results sent back to the Custom Search Portlet.
Sorting and displaying the results
We can use the compareTo method of Java and sort the results that we have received from WCM, IBM Connections, and Lotus Quickr, based on their relevance, and display the results in the UI (see listing 4).
Listing 4. Code for compareTo method
We can display the results by plugging the output ArrayList or the SearchObject into a Dojo Table format, JQuery table format, or a Custom JavaServer Page (JSP).
Pros and cons of the solution
The pros of the solution are as follows:
- Helps us to retrieve the search results from different sources, for example, WCM, Connections, Quickr etc.
- Helps us to display the results from different sources in a single/multiple UI. We can separate the search results coming from different sources and display them in different tabs. In this article we discussed displaying the Employee Profile information in a separate UI.
The cons are as follows:
- There would be a performance hit with this solution as we are getting the results from different sources and there would be a time delay in hitting a URL and retrieving the results. If possible, we can have a different Search Server dedicated for this activity to improve the performance.
- To obtain the results from Quickr for Domino, we must write a servlet, which is actually reading and writing files before transferring the information back to the Custom Portlet. This could again cause a performance issue. To overcome this, we can have an explicit option in the Search UI, so that the content is searched from Quickr only if selected by the user.
You should now be familiar with how to create your own custom search that searches various systems and retrieves the results. Here we've used the REST Services to get the search results, but the results can also be retrieved by use of a servlet, as shown in he Quickr for Domino section. You can use this approach in your applications.
Tell us what you think
Please visit this link to take a one-question survey about this article:
Connections product documentation topic, “Searching for information programmatically:”
Lotus Quickr wiki article, “Search REST API:”
developerWorks® WebSphere Portal zone:
About the author
is an IT Specialist with IBM's India Software Labs. His areas of specialization are WebSphere Portal, Web Content Manager, and IBM Forms. You can reach him at email@example.com