Passing queries to other search engines

You can use the ExternalSearchProvider interface to pass queries to another search engine. For example, an application on a BlackBerry® device that has an efficient way to search its own data could give users and other applications access to its data by implementing the ExternalSearchProvider. Alternatively, an insurance company may have an application that allows sales representatives to search an insurance policy database. The company could provide its sales representatives with access to the policy search engine behind the firewall, from a BlackBerry device, by implementing theExternalSearchProvider.

Users can extend a search in two ways. The Universal search feature from the Home screen lists external search providers at the end of the search result list. If a user clicks the icon for your application in the search result, the Unified Search Service invokes search() from your ExternalSearchProvider object. Your application is then responsible for creating a connection to the search provider (another application, or over a network), passing the query string, and displaying any results that you retrieve.

Other applications can invoke your application in a similar way. The UnifiedSearchServices.getSearchProviders() method returns a list of all external search providers that installed on a BlackBerry device. In this way, an application can find and use your ExternalSearchProvider specifically, or allow the user to choose one from the list.

To ensure that your application appears in the list of external search providers, you must register your ExternalSearchProvider with the Unified Search Service. Pass your ExternalSearchProvider object when you invoke SearchRegistry.register().

The following diagram shows the relationship between some of the components that required to implement ExternalSearchProvider.

This diagram shows the components involved in creating an external search provider.

Was this information helpful? Send us your comments.