Introduction
The global search in the top menu of EPiServer (OnlineCenter) features search functionality by aggregating results from several search providers. Any type of content can be searched and each provider reports results based on a specific category, for example, pages, blog posts or files.
For EPiServer three search providers are included:
- PageSearchProvider searches for CMS pages (including page content).
- FileSearchProvider searches for CMS documents.
- BlockSearchProvider searches for blocks.
Using the [SearchProvider] attribute
To add a custom search provider, you need to configure your assembly as a shell module (see documentation about shell modules). The next step is to implement the ISearchProvider interface and decorate the class with the [SearchProvider] attribute.
Properties
- Area is used to prioritize search providers in the current “area”. This means that search providers for the CMS area will be placed first when performing a search from the edit and admin interfaces.
- Category is used as display name in the user interface.
Methods
- Search returns an enumeration of hits for the given query.
Example
C#
[SearchProvider]
public class FilesSearchProvider : ISearchProvider
{
public string Area
{
get { return "CMS"; }
}
public string Category
{
get { return "Files"; }
}
public IEnumerable<SearchResult> Search(Query query)
{
return ...
}
}
Do you find this information helpful? Please log in to provide feedback.