Skip to content

What is an ElasticsearchIndexCreationStrategy

Phil Oyston edited this page Jun 5, 2017 · 2 revisions

As of v0.12.0 Nest.Indexify has been removed as a dependency, favouring a lighter implementation of the IElasticsearchIndexCreationStrategy interface that allows you to control the index creation process.

See the v7.7 sample for additional information.

[Deprecated] An ElasticsearchIndexCreationStrategy is a term derived from an associated library called Nest-Indexify. Within Nest-Indexify an index creation strategy abstracts the index creation process within the NEST library, providing a strategy and contribution model.

A strategy is a collection of contributors, with each contributor responsible for describing one part of the indexing process. Complete documentation should be available on the Nest-Indexify site (when I write it). In the mean time here is a briefly example:

internal class UmbracoElasticsearchIndexCreationStrategy : ElasticsearchIndexCreationStrategy
{
    public UmbracoElasticsearchIndexCreationStrategy(IElasticClient client) : base(client)
    {
        // contributes the English token analysis settings
        AddContributor(new EnglishIndexAnalysisContributor());
        
        // contributes the index settings, stating that the index should have 1 shard and 1 replica
        AddContributor(new IndexSettingsContributor(1, 1));
    }
}

The Nest-Indexify library contains a number of common contributors along with base classes for analysis, token and character filters to make further contributors easy to create.