Skip to content

Umbraco Integrations

Arkadiusz Biel edited this page Dec 14, 2022 · 3 revisions

Configuration

After installation Umbraco integration, you will need setup elastic, example for local elastic:

<add key="examine:ElasticSearch.internalindex.Url" value="http://localhost:9200" />

<add key="examine:ElasticSearch.externalindex.Url" value="http://localhost:9200" />

<add key="examine:ElasticSearch.memberindex.Url" value="http://localhost:9200" />

check more here: Configuration

Replacing custom Umbraco Index

  1. Locate Index creator for your custom Index (look for something similar to https://our.umbraco.com/Documentation/Reference/Searching/Examine/indexing/#overriding-index-creation): quite often package authors will register they custom index creators as direct type (example name CustomIndexCreator)
  2. Create Elastic Index Creator, example:
    public class ElasticCustomIndexCreator : LuceneIndexCreator
    {
        private readonly IProfilingLogger _profilingLogger;
        private readonly ILocalizationService _languageService;
        private readonly IPublicAccessService _publicAccessService;
        private readonly IUmbracoIndexConfig _umbracoIndexConfig;

        public ElasticCustomIndexCreator(
            IProfilingLogger profilingLogger,
            ILocalizationService languageService,
            IPublicAccessService publicAccessService, IUmbracoIndexConfig umbracoIndexConfig)
        {
            this._profilingLogger = profilingLogger;
            this._languageService = languageService;
            this._publicAccessService = publicAccessService;
            _umbracoIndexConfig = umbracoIndexConfig;
        }

        public override IEnumerable<IIndex> Create() 
        {
            return new List<IIndex>(){
                new ContentElasticSearchIndex("CustomIndex",
                    ElasticSearchConfig.GetConfig("CustomIndex"),
                    _profilingLogger,
                    new UmbracoFieldDefinitionCollection(),
                    "whitespace",
                    _umbracoIndexConfig.GetContentValueSetValidator())
               
            };
        }
    }

3.Create custom composer to override index:

 public class ElasticSearchComposer : ICoreComposer
    {
        public void Compose(Composition composition)
        {
            composition.RegisterUnique<ElasticCustomIndexCreator>();
        }
    }

make sure to tag composer with correct attribute [ComposeAfter()], as registration has to happen after original registration to override IndexCreator

Clone this wiki locally