ShowTable of Contents
Introduction
IBM® Lotus® Notes® provides users with several search engines out of the box; specifically, All Mail, All Calendar and All Contacts, Google and Yahoo Web searches, and desktop search integration on most platforms. However, many users and application developers would like to be able to customize their search options beyond those.
To address this, in Lotus Notes 8.x, IBM gave users the ability to write plug-ins to add Web search engines, as well as the ability to integrate third-party search engines into Lotus Notes. These third-party engines can leverage existing search UI's or create their own custom results views.
In addition, as of Notes 8.5.1 users have the ability to add Web and Notes Database search engines on the fly, without having to create a new plug-in.
In this article, we discuss both these plug-in-less extensions, as well how to create an advanced search application that fully leverages the Notes JavaTM Search framework.
Figure 1 shows an example Search List in Notes 8.5.x.
Figure 1. Notes Search List
Before we begin, make sure that the widgets toolbar is displayed by selecting Preferences –
widgets, and verifying that the “Show Widget Toolbar and My Widgets Sidebar panel” option is check marked (see figure 2).
Figure 2. Widgets Preferences window
As you may know, an increasing number of Web sites support the Open Search standard and declare their search components. One such example is
The Boston Globe's Web site, Boston.com.
Declaring Open Search support is quite easy. The home page simply includes the following tag:
The referenced search descriptor (see listing 1) is also fairly straightforward; all you really need is the search url and some basic tag/description information.
Listing 1. Referenced search descriptor
<OpenSearchDescription>
<ShortName>Boston.com</ShortName>
<Description>Search Boston information and news on Boston.com
</Description>
<Tags>news local boston massachusetts</Tags>
<Image height="16" width="16" type="image/png">
image data omitted.
</Image>
<Url type="text/html" method="GET" template="http://search.boston.com/local/Search.do?s.sm.query={searchTerms}&p1=search_toolbar_opensearch&camp=localsearch:on:plugin:opensearch"/>
<moz:SearchForm>http://search.boston.com/local/Search.do<moz:SearchForm>
<InputEncoding>UTF-8</InputEncoding>
<AdultContent>false</AdultContent>
<Developer>Joel Abrams</Developer>
<Contact>search-producer@boston.com</Contact>
</OpenSearchDescription>
Once you know that a site supports Open Search, adding it to Lotus Notes is easy. To do this:
1. Open the Notes Embedded Browser and navigate to the desired site.
2. Click the Configure a Widget from Current Context button from the widgets toolbar (see figure 3). The configuration wizard pops up.
Figure 3. Configure a widget from Boston.com
3. Select the Add Search Engine option and click Next (see figure 4).
Figure 4. Add Search Engine using the configuration wizard
4. Edit the engine title (if desired) in the next window of the wizard, and click Finish (see figure 5).
Figure 5. Edit engine name if desired
You now have a Boston.com search engine in your Notes Search List, as shown in figure 6.
Figure 6. Boston.com in your search list
This technology can be leveraged in two ways: (1) It lets you incorporate external Web sites that may add value to your business, and (2) it lets you easily add your internal sites to Lotus Notes by simply adding the Open Search header to pages containing search capability.
Adding Notes views to the Search List
Context-based search was added in earlier versions of Lotus Notes; if you opened a Notes database, the option to search the current view—as well as the All Documents view—was automatically added to the Search List.
This is great if you are already in the database that you want to search, but if you need to search a different database, you must first open the database, wait for the view to load, and then search.
So in version 8.5.1, the ability was added for users to permanently add their Notes databases to the Search List. To do this:
1. Navigate to the database you want to add, and click on the Search List (see figure 7).
Figure 7. Notes 8.5.1 database
2. As in the previous example, click the Configure a Widget from Current Context button from the widgets toolbar and ensure that the “Add as an engine to the Search Center” box is checked (see figure 8).
Figure 8. Notes Widget Configuration wizard
3. Click “Next”, edit the engine name if desired, and click “Finish”. Close the database.
4. If you now click on the Search List, you will see that your database has been permanently added to the list of engines and you can search your database as often as you like, without having to open it first.
Figure 9. New Notes database search added to Search List
Another way to perform the same task is to:
1. Open the database, click on the Search List drop down, and click the “Always show in Search List” link under the desired engine (see figure 10).
Figure 10. New Options in Search List
2. After that, edit the title and click “OK” (see figure 11).
Figure 11. Notes Engine Title window
3. Close the database and open the Search List; the database has been permanently added (see figure 12).
Figure 12. New Notes engine added
4. Note that when you open the database, the contextual engines still become the default (see figure 13).
Figure 13. Permanent engine becomes default when its database is opened
Managing the engine
If you are familiar with the Notes widgets framework, you may have realized that these new engines can also be managed through the widgets framework. In particular, you can share these directly with other users, publish them to the widgets catalog, and remove them.
To perform any of these tasks, simply open the My Widgets sidebar panel, and right-click any of the newly added engine widgets (see figure 14).
Figure 14. Switching to Details view
To find the desired engine, in the Details view, the widget type is “Search List Engine” (see figure 15), or you can simply find the related thumbnail in the Thumbnails view (see figure 16).
Figure 15. Engine actions
Figure 16. Thumbnails view
Building your own search engines
All the above options are great. However, suppose you simply want to show results from a Java search application, which runs standalone and can be deployed within Lotus Notes as a plug-in, but you simply don't want to create a UI for it?
To do this, we use the SearchEngineDelegate (see listing 2). The search engine delegate allows you to create a simple interface between an already-existing search engine and the Notes Search Center.
Listing 2. SearchEngineDelegate
A quick overview of the methods in SearchEngineDelegate above reveals the Javadoc comments. Rather than belabor the somewhat obvious, let's see if we can build a simple engine and plug into the Notes and the Search Center.
For our purposes, we just want to build an engine that is able to:
- Look in the “My Program Files”, “My Documents” and “My Pictures” folders and find files whose name contains a certain string
- Look in all three folders at once, or in each one separately
- Sort our results by date or in alphabetical order (for real search results, you'd want relevance, as well)
- Be plugged into the Search Center
To specify where we want to search, we need to implement the
getLocations method of the SearchEngineDelegate. It's fairly straightforward; we just define
SearchLocations that consist of an ID and label (see listing 3).
Listing 3. getLocations() method
The ID is what the engine uses to decide where to search, and the label is what the user sees in the search scope selection drop-down list (see figure 17).
Figure 17. Locations
Now that we have locations, let's look at sort options. Sort options also consist of an ID and a label, as well as whether or not the option is the default (see listing 4 and figure 18).
Listing 4. getSortOptions() method
Figure 18. Sort options
Now that we have given users the ability to specify locations and sort options, we just need to implement the actual search code. The search query that is passed into the search method includes the search string, the location, and the sort option selected by the user (see listing 5).
We simply need to pick a directory, find the matching files, sort them, and return them as a Search Results page.
Listing 5. Search method
Now we have a search method. For the purposes of this exercise, we are ignoring the “setData” method, but you can use it to set state for the engine.
So now, all we must do is add our new engine to the Search Center. We already have a plug-in that contains our search engine, so we just need to add extensions to the plugin.xml file that specifies your engine, and how it should be contributed to the Search Center (see listing 6).
Listing 6. Add engine to Search Center
where:
- the com.ibm.rcp.search.engines.searchEngines extension point declares our search engine in the Notes client,
- setting the hasResults attribute to true tells Lotus Notes that you want to return your results in the Search Center,
- the icon attribute allows you to specify the icon for your engine,
- and the engine attribute specifies the class for your newly created engine.
and:
- the com.ibm.rcp.search.ui.searchBarSets extension point specifies how your engine should be contributed to the Search Center drop-down in the upper right-hand side (see figure 19),
- the path attribute defines in which category you want your engine to appear (legal values are separate, top, application, additions, web, advanced, desktop, bottom, and create),
- and searchBarItem specifies the ID of your search engine.
The finished product looks like that shown in figure 19.
Figure 19. Simple File Search Engine implementation
Conclusion
From simply adding Web and Notes sources on the fly, to writing complete search applications, Lotus Notes now provides a variety of ways to provide a customized search experience. Users can leverage the My Widgets-driven addition of Web Sites and Notes Databases to expand their search lists. Business partners can leverage the search infrastructure to create custom plug-ins that interface with other search products, such as Google Desktop, Spotlight, and Lotus Connections.
Being able to perform more searches without leaving Lotus Notes should yield a net increase in user productivity.
Resources
developerWorks® Lotus Notes documentation:
https://www.ibm.com/developerworks/lotus/documentation/notes/
Lotus Notes and Domino product page:
http://www.ibm.com/developerworks/lotus/products/notesdomino/
IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler):
http://www-10.lotus.com/ldd/nd85forum.nsf?OpenDatabase
About the author
Igor Belakovskiy is the Lead Developer for the Java Search Infrastructure of Lotus Notes.