如何在 play2-elasticsearch 中设置 ttl "time to live"

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

我如何在索引上设置 "ttl" "time to live"(这样所有早于“60s”的结果都会从搜索中删除,例如在 play2-elasticsearch (https://github.com/cleverage/play2-elasticsearch) 中。

在经典的弹性搜索中,可以用 https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-ttl-field.html

play2-elasticsearch 有设置选项,我尝试使用此更改


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

但即使在一小时后仍然可以搜索到结果。

我的搜索结果实体是这样注释的:


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

 @IndexMapping(value = "{ searchResult : { \"_ttl\" : { \"enabled\" : true , \"default\" : \"12h\"} } }") 

(问题单 https://github.com/cleverage/play2-elasticsearch/issues/64 已回答)