[英]How to use ttl in elasticsearch bulk api (NEST)
I'm trying to use bulk API using NEST client. 我正在尝试通过NEST客户端使用批量API。 How can I specify a TTL value based on an attribute of a collection. 如何根据集合的属性指定TTL值。 Consider the following code snippet, how can I specify a "ttl" to say person.Age > 50 --> 1 month, otherwise 6 months?: 考虑以下代码片段,如何指定“ ttl”来表示person.Age> 50-> 1个月,否则为6个月?:
var coll = new List<Person>();
// fill the collection from db etc...
var desc = new BulkDescriptor();
foreach(var p in coll)
{
// desc.Index<Person>( .... );
// How can I say, "if person.Age > 50, ttl = 1 month, otherwise 6 months?
}
var result = client.Bulk(desc);
desc.Index<Person>(i => i
.Document(p)
.Ttl(p.Age > 50 ? "1M" : "6M")
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.