How to set ttl "time to live" in play2-elasticsearch

100 views Asked by At

How can i set "ttl" "time to live" on index (so all results older than "60s" would get removed from search for example in play2-elasticsearch (https://github.com/cleverage/play2-elasticsearch) .

In classic elastic search it could be done with https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-ttl-field.html

play2-elasticsearch has option for settings, i tried to use this change


    ## Custom settings to apply when creating the index (optional)
    elasticsearch.index.settings="{'_ttl' : { 'enabled' : true, 'default' : '60s' }"

But results are still searchable even after hour.

My search result entity is annotated this way :


    @IndexType(name = "searchResult") 
    public class SearchResult extends Index { ...

1

There are 1 answers

0
Jiro Matchonson On BEST ANSWER
 @IndexMapping(value = "{ searchResult : { \"_ttl\" : { \"enabled\" : true , \"default\" : \"12h\"} } }") 

(answered by issue ticket https://github.com/cleverage/play2-elasticsearch/issues/64)