Reputation: 307
I am using elastic4s to implement elastic search. I am trying to enable ttl but I couldn't figure it out how ? I mean yes _ttl enabled is going to be true but within the code where and how should I be implementing it ? I am using the latest version 1.3.2 for elastic4s
Upvotes: 1
Views: 208
Reputation: 3616
If you already enabled it, when all you need is to pass it as a field when indexing documents, like:
index into "documents/doc" fields (
"title" -> document.title,
"description" -> document.description,
"_ttl" -> 30.minutes.toMillis // TTL should be passed as milliseconds number
)
UPD: Also, there is special DSL support in elastic4s for ttl:
index into "documents/doc" ttl 30.minutes.toMillis fields (
"title" -> document.title,
"description" -> document.description
)
Upvotes: 1