问题
I need to set index.query.default_field while creating index.How can I do it using Nest client c#. Added my create index code.Where do I set default_field property?
var fullNameFilters = new List<string> { "lowercase", "snowball" };
client.CreateIndex("mydocs", c => c
.Settings(st => st
.Analysis(anl => anl
.Analyzers(h => h
.Custom("full", ff => ff
.Filters(fullNameFilters)
.Tokenizer("standard"))
)
.TokenFilters(ba => ba
.Snowball("snowball", sn => sn
.Language(SnowballLanguage.English)))
))
.Mappings(mp => mp
.Map<IndexDocument>(ms => ms
.AutoMap()
.Properties(ps => ps
.Nested<Attachment>(n => n
.Name(sc => sc.File)
.AutoMap()
))
.Properties(at => at
.Attachment(a => a.Name(o => o.File)
.FileField(fl=>fl.Analyzer("full"))
.TitleField(t => t.Name(x => x.Title)
.Analyzer("full")
.TermVector(TermVectorOption.WithPositionsOffsets)
)))
))
);
回答1:
You can use Settings method when creating index:
var createIndexResponse =
client.CreateIndex(indexName, c => c
.Settings(s => s.Setting("index.query.default_field", "field"))
.Mappings(m => m
.Map<Document>(mp => mp.AutoMap())));
Hope it helps.
来源:https://stackoverflow.com/questions/37967551/set-index-query-default-field-using-nest-client-c-sharp