NEST 7 忽略 属性 映射但在 _source 中仍然可用
NEST 7 ignore a property mapping but still available in _source
如何使用 NEST 7 客户端转换此映射。我正在尝试将启用设置设置为 false。这将导致 Elasticsearch 完全跳过对该字段内容的解析,但仍可从 _source 获得它。
PUT my_index
{
"mappings": {
"properties": {
"user_id": {
"type": "keyword"
},
"last_updated": {
"type": "date"
},
"session_data": {
"type": "object",
"enabled": false
}
}
}
}
一种方法是使用 attribute mapping
await client.Indices.CreateAsync("documents", c => c
.Map<Document>(m => m.AutoMap()));
public class Document
{
public string Id { get; set; }
[Object(Enabled = false)]
public object Data { get; set; }
}
另一种是使用fluent mapping
await client.Indices.CreateAsync("documents", c => c
.Map<Document>(m => m
.Properties(p => p.Object<object>(o => o.Name(n => n.Data).Enabled(false)))));
您可以在 docs 中找到更多信息。
希望对您有所帮助。
如何使用 NEST 7 客户端转换此映射。我正在尝试将启用设置设置为 false。这将导致 Elasticsearch 完全跳过对该字段内容的解析,但仍可从 _source 获得它。
PUT my_index
{
"mappings": {
"properties": {
"user_id": {
"type": "keyword"
},
"last_updated": {
"type": "date"
},
"session_data": {
"type": "object",
"enabled": false
}
}
}
}
一种方法是使用 attribute mapping
await client.Indices.CreateAsync("documents", c => c
.Map<Document>(m => m.AutoMap()));
public class Document
{
public string Id { get; set; }
[Object(Enabled = false)]
public object Data { get; set; }
}
另一种是使用fluent mapping
await client.Indices.CreateAsync("documents", c => c
.Map<Document>(m => m
.Properties(p => p.Object<object>(o => o.Name(n => n.Data).Enabled(false)))));
您可以在 docs 中找到更多信息。
希望对您有所帮助。