我正在使用elastic4s来实现弹性搜索。我正在尝试启用ttl,但是我不知道如何启用它?我的意思是,是的,启用_ttl将是正确的,但在代码中,我应该在哪里以及如何实现它?我使用的是elastic4s的最新版本1.3.2
发布于 2014-09-30 01:15:45
如果您已经启用了它,那么您所需要的就是在索引文档时将其作为字段传递,例如:
index into "documents/doc" fields (
"title" -> document.title,
"description" -> document.description,
"_ttl" -> 30.minutes.toMillis // TTL should be passed as milliseconds number
)更新:另外,在elastic4s中有对ttl的特殊数字用户线支持:
index into "documents/doc" ttl 30.minutes.toMillis fields (
"title" -> document.title,
"description" -> document.description
)https://stackoverflow.com/questions/26096746
复制相似问题