[英]Nest Update By Id That Is Auto Generated By ElasticDb
我使用Nest 6.X框架通过c#管理ElasticSearch,在那儿我共享了嵌套查询的结果。
像这样的C#代码
_elasticSearchDb.Update(DocumentPath<myElasticType>.Id("Cq2jmGgB5bes6sABU8NP"), u => u.DocAsUpsert(true).Doc(myObject));
我想通过Elasticsearch自动生成的documentId更新索引中的文档。
在这一点上,我没有任何问题。
现在以为我在elasticdb上有1个副本和5个分片。
当我要执行此更新进度时,我有一些疑问。 例如,每天我在不同的时间向弹性搜索发送请求,一天结束时总共发送5000个请求。
在这一点上,我可以在弹性数据库上有任何性能问题吗?
这是Nest生成的Elaastic原始查询请求和响应
注意:myElasticIndex和myElasticType术语用作傻瓜
Valid NEST response built from a successful low level call on POST: /myElasticIndex/myElasticType/Cq2jmGgB5bes6sABU8NP/_update
# Audit trail of this API call:
- [1] HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.0189528
# Request:
{
"doc_as_upsert": true,
"doc": {
"person": "Eyup Can ARSLAN",
"recordDate": "2019-01-29",
"field3": "field3 data",
"field4": "field 4 data"
}
}
# Response:
{
"_index": "myElasticIndex",
"_type": "myElasticType",
"_id": "Cq2jmGgB5bes6sABU8NP",
"_version": 3,
"result": "noop",
"_shards": {
"total": 0,
"successful": 0,
"failed": 0
}
}
如果您有想要更新的文档及其ID,则可以使用Bulk API批量发送它们
var client = new ElasticClient();
var updates = new Dictionary<string, object>
{
{ "id1", new { foo = "bar" } },
{ "id2", new { foo = "baz" } }
};
var bulkResponse = client.Bulk(b =>
{
b.Index("my_index").Type("my_type");
foreach(var update in updates)
{
b.Update<object>(u => u
.Id(update.Key)
.DocAsUpsert()
.Doc(update.Value)
);
}
return b;
});
更新的TValue
通用参数可以是您的POCO类型。 这发送以下请求
POST http://localhost:9200/my_index/my_type/_bulk
{"update":{"_id":"id1"}}
{"doc_as_upsert":true,"doc":{"foo":"bar"}}
{"update":{"_id":"id2"}}
{"doc_as_upsert":true,"doc":{"foo":"baz"}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.