我需要在创建index时设置index.query.default_field。如何使用Nest client c#来实现。添加了我的创建索引代码。我在哪里设置default_field属性?
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)
)))
))
);
答案 0 :(得分:1)
创建索引时可以使用Settings
方法:
var createIndexResponse =
client.CreateIndex(indexName, c => c
.Settings(s => s.Setting("index.query.default_field", "field"))
.Mappings(m => m
.Map<Document>(mp => mp.AutoMap())));
希望它有所帮助。