I would like to add mappings to an index after I've created it. I've created the index as such:
client.CreateIndex("typeaheads", c => c
.Settings(t => t.Analysis(m => m.TokenFilters(fl => fl.EdgeNGram("edge_ngram_filter", ad => ad.MinGram(2).MaxGram(20)))
.Analyzers(anz => anz.Custom("edge_ngram_analyzer", an => an.Filters("lowercase", "edge_ngram_filter").Tokenizer("standard"))))));
The variable typeName, is the name I want for the mapping.
When I execute this:
var map = new CreateIndexDescriptor("typeaheads")
.Mappings(ms => ms
.Map(typeName, d => d.Properties(ps => ps.String(s => s.Name("countryCode")))
.Properties(ps => ps.String(s => s.Name("display_ID")))
.Properties(ps => ps.String(s => s.Name("display_String")))
.Properties(ps => ps.String(s => s.Name("id")))
.Properties(ps => ps.String(s => s.Name("languageCode")))
.Properties(ps => ps.String(s => s.Name("match_String").SearchAnalyzer("standard").Index(FieldIndexOption.Analyzed).Analyzer("edge_ngram_analyzer")))
.Properties(ps => ps.String(s => s.Name("type")))
.Properties(ps => ps.Number(s => s.Name("boostFactor").Type(NumberType.Long)))));
var response = client.Index(map);
I get this output on my ES service: Wrong Mapping
I would like to get this: Correct Mapping
Any ideas?
If you have an existing index and wish to add a mapping to it, this can be done with the Put Mapping API, exposed in NEST as
client.Map<T>()
andclient.MapAsync<T>()
which sends the following request