Connect to search service

You connect to third party search service by implementing the ISearchService interface and replacing the registration using ServiceBus.RegisterService(service). ISearchService is the interface of the application service in Sitefinity CMS that is responsible for the full text search capabilities of the system.

The default, implementation in Sitefinity CMS uses Lucene.Net and stores generated search indexes locally. Sitefinity CMS also includes additional implementations for storing search indexes in the cloud on Azure Search and on Elasticsearch servers.

The default implementations are listed under Settings » Advanved » Search » Search Services. You can chance the default services by editing their TypeName field. You can also add your own custom search service implementations.

When you implement this interface and replace the default implementation with a your custom one, Sitefinity CMS can interface with other external search services, such as Solr, SharePoint Search, etc.

You replace the default implementation when you register the interface 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 as an argument. 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's 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 usually contains static clauses like language filtering, type filtering, date filtering, or any other custom filtering.

Amazon CloudSearch

In addition to the cloud search and indexing services built into Sitefinity CMS, a full sample of connecting and using Amazon CloudSearch is available on GitHub at Amazon CloudSearch Sample.

Was this article helpful?