Exposing your application data

The Unified Search Service maintains an index of content on a BlackBerry® device. Your application uses the SearchRegistry, AppContentManager, and AppContentListener classes to communicate with the Unified Search Service. To make the data in your application findable, you need to complete five tasks.

Task

Description

Define an EntityBasedSearchable class for your SearchableEntity objects.

An EntityBasedSearchable object represents your searchable data to the Unified Search Service. When you register your EntityBasedSearchable, the Service requests that your application prepare data for submission by calling EntityBasedSearchable.load(). When your application data is ready for submission, you should invoke completed() on the NotificationListener parameter passed to load().

Encapsulate your data in a SearchableEntity object.

A SearchableEntity object is the smallest unit of data that an application can submit to the Unified Search Service. Your EntityBasedSearchable object sends your SearchableEntity objects to the Service when asked. You need to encapsulate your application data in a SearchableEntity object. The Service indexes the metadata that is exposed by these objects for consideration during search operations. Also, SearchableEntity objects are returned in search results from the Service.

The Unified Search Service may need interrupt your load operation if the BlackBerry device is busy, or has a low battery power level. If an interruption is necessary, the Service invokes EntityBasedSearchable.pause(). When the Service detects that your operation can continue, it invokes EntityBasedSearchable.resume(). Respond to these events in a timely manner so that your application does not cause disruption to other applications on the device.

After you notify the Unified Search Service that your data is ready, it calls EntityBasedSearchable.getSearchableEntities() to index your data. The Service may invoke load() and getSearchableEntities() again if it detects that its content index and your data are not synchronized.

Register your EntityBasedSearchable object with the Unified Search Service.

After you prepare your data for search, and define how it will be indexed, you must register your EntityBasedSearchable with the Unified Search Service. Pass your EntityBasedSearchable when you invoke SearchRegistry.register(). The Service then retrieves and indexes your data for inclusion in search results.

Notify the Unified Search Service about changes to your data.

To notify the content index about changes to your application data, use the insert(), delete(), and update() methods in the AppContentManager object.

Listening for responses from the Unified Search Service.

When you notify the Unified Search Service about changes to your application data, you should provide an AppContentListener object where the Service can notify your application about the result of your request.

The following diagram illustrates the relationship between the components that are used in the previous tasks.

This diagram shows the relationship between the components used to add your content to the Unified Search Service.
Previous topic: Making data findable

Was this information helpful? Send us your comments.