Integration Application Event Handler - Philo/Umbraco.Elasticsearch GitHub Wiki
When Umbraco starts it scans all the available assemblies for classes derived from ApplicationEventHandler
. Umbraco.Elasticsearch has a SearchApplicationEventHandler
that must be derived from within your application. This class will tell Umbraco.Elasticsearch how and where to index your content, in addition Umbraco.Elasticsearch will attach itself to a number of Umbraco events to ensure it is notified of important activities within the CMS.
- Content Published/Unpublished/Trashed
- Media Saved/Deleted
These events will trigger Elasticsearch indexing actions for configured content and media types.
You create a new class and derive it from the SearchApplictionEventHandler
, where you will be required to implement a number of methods that describe:
- how you want your search index to be created via an
ElasticsearchIndexCreationStrategy
- which nodes you want to be indexed via an indexing service
public class UmbracoElasticsearchStartup : SearchApplicationEventHandler
{
protected override IElasticsearchIndexCreationStrategy GetIndexCreationStrategy(IElasticClient client)
{
return new UmbracoElasticsearchIndexCreationStrategy(client);
}
protected override IEnumerable<IContentIndexService> RegisterContentIndexingServices()
{
yield return new ArticleContentIndexService();
}
protected override IEnumerable<IMediaIndexService> RegisterMediaIndexingServices()
{
return Enumerable.Empty<IMediaIndexService>();
}
}