gpt4 book ai didi

c# - 使用NEST Client C#设置index.query.default_field

转载 作者:行者123 更新时间:2023-12-03 01:54:05 25 4
gpt4 key购买 nike

创建索引时需要设置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)
)))

))
);

最佳答案

您可以在创建索引时使用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())));

希望能帮助到你。

关于c# - 使用NEST Client C#设置index.query.default_field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37967551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com