Federated search enables users to query external data repositories while remaining in the Salesforce user interface. It became generally available with the Summer ’17 release, and works in both Lightning Experience and Salesforce Classic. In this post, I show you how easy it is to set up federated search and to include it in your app’s managed package for one-click installation by your customers.
Federated search offers a great opportunity for ISVs to add value to their solutions. For example, you can enable your customers to search off-platform product catalogs, CAD drawings, audio or video files, archived documents, and so on—all from within the Salesforce UI.
Federated search architecture
The diagram below illustrates the flow of data among the various components of Salesforce federated search. It all starts when a user enters a string in the global search box, located at the top of every Salesforce page. The federated search connector forwards the request to an external provider via the Salesforce Federated Search API, which is based on the OpenSearch standard. The search provider queries the data repository and returns the results to Salesforce for display to the user.
- A user enters a text string in the Salesforce global search box, initiating a search of both on- and off-platform data.
- Salesforce sends the search request to the federated search connector.
- The federated search connector sends the request via the Salesforce Federated Search API to the external search provider.
- The external search provider searches the external data repository index.
- The external search provider gets results from the external data repository index.
- The external search provider returns the results to the federated search connector.
- The federated search connector returns the results, which are displayed in the Salesforce search results page.
Setting up federated search
This help article has detailed instructions for setting up Salesforce federated search. It’s very easy, especially if the external search provider conforms to the OpenSearch API and satisfies the constraints of the Salesforce Federated Search API (see Chapter 2, “Constraints”).
Let’s try an example: say we want to enable users of our application to search articles from the scientific research journal Nature.com, and view an excerpt of the article within the Salesforce user interface. (For your real-world ISV app, verify your right to use the external search provider and its data.) Follow the instructions to set up an external data source, using these values below:
|External Data Source||Nature|
|Type||Federated Search: OpenSearch|
|Connection Timeout (Seconds)||30|
|Search results visible to all profiles||[Unchecked]
Note: leave this option unchecked, and then manage the per-profile visibility of search results later. Doing so will speed up the “validate and sync” phase of the external data source definition.
|Authentication Protocol||No Authentication|
Press Save, then Validate and Sync to initialize the connection to the external search provider. Exit the setup mode, and return to the main Salesforce UI.
In the global search box at the top of the page, enter a string; I searched for “volcano,” as you can see in the screenshot below. The search connector forwards the request to the external search provider, and within a few seconds voila! The results come directly from Nature.com’s content database, but are displayed just as if they had been stored in Salesforce. To customize the display, go to Setup > External Objects > Nature and edit the search layout or page layout for the external object, just as you do for a standard object.
If the external search provider doesn’t conform to the OpenSearch API, then you can use Google’s Custom Search Engine to set up a conforming interface between Salesforce and the search provider. For example, in just a few minutes, I configured a Google Custom Search Engine to query Eventbrite’s huge database of local events, and then hooked it up to Salesforce federated search. The screenshot below shows the results of a search for “salesforce user group.”
You can configure a similar Google Custom Search Engine for almost any website—or even a set of websites—then simply create an XML-formatted description file, host it on an Internet-accessible site, and enter its URL in the OpenSearchDescription URL field, per the instructions for setting up a Salesforce external data source. Below is the description file I used for the Eventbrite external data source (replace “xxx” with your own Google API key, and “yyy” with your Google Custom Search Engine ID):
If your company manages its own external data repository or wants to create one, then you can use the Salesforce Federated Search API to build a conforming external search provider. See the Salesforce Federated Search Developer Guide for more information and examples. You can also work with Salesforce’s search provider partners, Coveo, Docurated, or Swiftype, to set up federated search for content repositories like Dropbox, Confluence, or SharePoint.
Packaging federated search
It’s very easy to include federated search capability in your managed package. Go to the Package Manager, add the custom external object that was created when you defined the external data source (here are the instructions again). Package Manager also pulls in the related data source, the custom fields, and any customized page layouts. The screenshot below shows my packaged federated search for the aforementioned Nature example.
You’ve seen how easy it is to configure and package federated search so your customers can quickly search external repositories from within the Salesforce user interface.
If you’d like more information on federated search, check out these resources:
- Federated Search Developer Guide
- Define an External Data Source for Federated Search: OpenSearch
- Considerations for Federated Search
- Search Limits for Federated Search
- How Results from External Search Providers Appear to Users
- Summer ’17 Release Notes: See Results from External Search Engines with Federated Search (Generally Available)
- Search Solutions Basics on Trailhead
- Knowledge Search Basics on Trailhead
- Additional Trailhead modules related to search
If you have any questions or comments, please post them below, or reach out to me on Twitter at @mike4aday.
Many thanks to Bruno Roustant for his invaluable assistance.
About the author
Michael Epstein is a senior technical evangelist at Salesforce and works with ISV partners who are building applications on the Salesforce platform.
LinkedIn: in/mike4aday | twitter: @mike4aday