gpt4 book ai didi

elasticsearch - 如何在NEST Elasticsearch 嵌套属性映射中添加字段?

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

 "properties": {
"data": {
"type": "text",
"boost": 2,
"fields": {
"raw": {
"type": "text"
}
}

我需要实用地添加字段,在上面的代码中,我需要添加data.raw。请帮忙。提前致谢。

最佳答案

无法通过属性映射添加multi_fields。为此,您需要使用fluent mapping

void Main()
{
var client = new ElasticClient();

client.CreateIndex("index-name", c => c
.Mappings(m => m
.Map<Test>(mm => mm
.AutoMap()
.Properties(p => p
.Text(t => t
.Name(n => n.Data)
.Boost(2)
.Fields(ff => ff
.Text(tt => tt
.Name("raw")
)
)
)
)
)
)
);
}

public class Test
{
public string Data { get; set; }
}

关于elasticsearch - 如何在NEST Elasticsearch 嵌套属性映射中添加字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44368261/

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