[英]How to update an existing document inside an ElasticSearch index using NEST?
[英]How to index a document using Elasticsearch NEST dynamically?
我想将来自不同客户的文档放到 Elasticsearch 中的不同索引中。 文档在结构上有一些共同的部分和一个因客户而异的部分,名为Data 。
C#
class Entity
{
public Guid CustomerId { get; set; }
public IDictionary<string, object> Data { get; set; }
}
JSON
{
"customerId": "10000000-0000-0000-0000-000000000000",
"data": {......}
}
假设我们有 10000 个“客户”,每个客户都有一百万份文档。 “客户”可以动态创建和删除。
将来自不同客户的文档放到 Elasticsearch 中的不同索引中是个好主意吗?
是否可以根据插入文档的customerId字段在 Elasticsearch 中动态创建新索引? 使用.Net客户端怎么做?
我正在寻找类似的东西:
var index = entity.CustomerId;
client.CreateDocument<Entity>(entity, index);
PS我正在使用Elasticsearch v7.6
嗯,我找到了答案。 无论如何,如果有人评论它在战略上有多好,那就太好了。
这里我们 go:
var indexName = entity.CustomerId.ToString();
var request = new IndexRequest<Entity>(entity, indexName);
client.Index<Entity>(entity);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.