使用 NEST Client c# 设置 index.query.default_field
Set index.query.default_field using NEST Client c#
我需要在创建 index.How 时设置 index.query.default_field 我可以使用 Nest 客户端 c# 来完成吗?添加了我的创建索引 code.Where do I set 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)
)))
))
);
创建索引时可以使用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())));
希望对您有所帮助。
我需要在创建 index.How 时设置 index.query.default_field 我可以使用 Nest 客户端 c# 来完成吗?添加了我的创建索引 code.Where do I set 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)
)))
))
);
创建索引时可以使用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())));
希望对您有所帮助。