Disclaimer: This website requires JavaScript to function properly. Some features may not work as expected. Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Add search providers

Describes how to add a search provider.

The global search in the global menu of Optimizely features search functionality by aggregating results from several search providers. You can search any type of content, and each provider reports results based on a specific category, such as pages, blog posts, or files.

For Optimizely, the following search providers are included:

  • PageSearchProvider searches for Optimizely Content Management System (CMS) pages (including page content).
  • FileSearchProvider searches for CMS documents.
  • BlockSearchProvider searches for blocks.

[SearchProvider] attribute

To add a custom search provider, configure your assembly as a shell module (see Configuring Shell modules. Next, implement the ISearchProvider interface and decorate the class with the [SearchProvider] attribute.

Properties

  • Area prioritizes search providers in the current area such that search providers for the CMS area are placed first when performing a search from the edit and admin interfaces.
  • Category is a display name in the user interface.

Methods

  • Search returns an enumeration of results for the given query.

Example

[SearchProvider]
public class FileSearchProvider: ISearchProvider {
  /// <summary>
  ///   Area that the provider mapps to, used for spotlight searching
  /// </summary>
  public string Area {
    get {
      return "CMS";
    }
  }

  /// <summary>
  ///   The category that the provider returns hits in
  /// </summary>
  public string Category {
    get {
      return "Files";
    }
  }

  public IEnumerable<SearchResult> Search(Query query) {
    return...
  }
}