Create a custom search service

Sitefinity CMS supports the following search services out of the box: Lucene.NET (default service), Azure Cognitive Search service, and Elasticsearch service. If support for another search service is needed (such as Solr, SharePoint Search, etc.), you can accomplish this with custom code. The ISearchService interface must be implemented and then to replace the default service, the interface should be registered by invoking ObjectFactory.RegisterType.

Sitefinity CMS calls the UpdateIndex method of the your implementation when you create and modify each item. It provides a collection of IDocument instances to be added or updated in the index.

The Search method of the registered interface (either the built-in or a custom implementation) is invoked whenever the user uses the Search widget. If the Search widget is not used on your Sitefinity CMS site, the other interface methods can be used in order to run a search query directly through the API.

The Search method takes ISearchQuery and SearchOptions as arguments. SearchOptions are specifically used for defining the search type, scoring settings when search scoring is required (only available for Azure Cognitive Search service) or if search facets are required (available for Azure Cognitive Search and Elasticsearch services). In the default implementation, the query is instantiated and its ISearchGroup groups are built with the BuildQuery method of the IQueryBuilder interface. You can add or remove groups to the query once it is built.
ISearchGroup consists of ISearchTerm and ISearchGroup enumerations. When building the search expression, the group operator is used between the terms and the groups.
ISearchTerm describes a search term with its Field and Value. In most cases, terms contains the search field names and the text that the user is searching for.
ISearchFilter defines a search filter for the search query. The filter normally contains static clauses like language filtering, type filtering, date filtering, or any other custom filtering.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Index external content