You can change the default analyzer for all text
fields within an index by adding an analyzer with the name "default"
to the index settings when creating the index
var defaultIndex = "my_index";
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(pool)
.DefaultIndex(defaultIndex);
var client = new ElasticClient(settings);
var createIndexResponse = client.CreateIndex(defaultIndex, c => c
.Settings(s => s
.Analysis(a => a
.Analyzers(an => an
.Standard("default", st => st
.StopWords("_english_")
)
)
)
)
);
which will send a create index request with the following body
{
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "standard",
"stopwords": [
"_english_"
]
}
}
}
}
}
If you wanted this to apply to all indices created, you can use an index template to apply this convention to all automatically created indices
var putIndexTemplateResponse = client.PutIndexTemplate("default_analyzer", t => t
.IndexPatterns("*")
.Order(0)
.Settings(s => s
.Analysis(a => a
.Analyzers(an => an
.Standard("default", st => st
.StopWords("_english_")
)
)
)
)
);