我正在使用elastic4s实现 flex 搜索。我正在尝试启用ttl,但我不知道怎么办?我的意思是,启用_ttl是正确的,但是在代码中,我应该在哪里以及如何实现它?我正在为Elastic4s使用最新版本1.3.2
最佳答案
如果您已启用它,则在编制文档索引时,只需要将其作为字段传递即可,例如:
index into "documents/doc" fields (
"title" -> document.title,
"description" -> document.description,
"_ttl" -> 30.minutes.toMillis // TTL should be passed as milliseconds number
)
UPD:另外,ttl的elastic4s中有特殊的DSL支持:
index into "documents/doc" ttl 30.minutes.toMillis fields (
"title" -> document.title,
"description" -> document.description
)
关于scala - 使用elastic4s在Scala中启用ttl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26096746/