【问题标题】:How to set ttl "time to live" in play2-elasticsearch如何在play2-elasticsearch中设置ttl“生存时间”
【发布时间】:2015-07-09 06:54:26
【问题描述】:

如何在索引上设置“ttl”“生存时间”(因此所有早于“60s”的结果都将从搜索中删除,例如在 play2-elasticsearch (https://github.com/cleverage/play2-elasticsearch) 中。

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

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

## 创建索引时应用的​​自定义设置(可选) elasticsearch.index.settings="{'_ttl' : { 'enabled' : true, 'default' : '60s' }"

但即使过了一小时,结果仍然可以搜索。

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

@IndexType(name = "searchResult") 公共类 SearchResult 扩展索引 { ...

【问题讨论】:

    标签: elasticsearch playframework ttl


    【解决方案1】:
     @IndexMapping(value = "{ searchResult : { \"_ttl\" : { \"enabled\" : true , \"default\" : \"12h\"} } }") 

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

    【讨论】:

      猜你喜欢
      • 2022-10-05
      • 2019-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-17
      相关资源
      最近更新 更多