我正在使用elasticsearch-model(https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model),但我找不到在文档上设置TTL的方法。我尝试了几种方法但没有成功。
我有一个名为" log"和一个名为" logs"的索引。在模型中,我有以下映射:
> Log.mappings
=> #<Elasticsearch::Model::Indexing::Mappings:0x007fcefd985368 @mapping={}, @options={:_ttl=>{:enabled=>true, :default=>"7d"}}, @type="log">
类似
在控制台中,我可以看到这一点:
curl -XGET 'http://localhost:9200/logs/_mappings'
{
"logs": {
"mappings": {
"log": {
"properties": {
"created_at": {
"format": "dateOptionalTime",
"type": "date"
},
"id": {
"type": "long"
},
"operation": {
"type": "string"
},
"order_number": {
"type": "string"
},
"request_payload": {
"type": "string"
},
"response_payload": {
"type": "string"
},
"updated_at": {
"format": "dateOptionalTime",
"type": "date"
}
}
}
}
}
}
但是,在使用cURL时,我只能使用模型属性而不能使用ttl选项:
> Log.import({
query: -> { where(id: ids) },
refresh: true,
return: 'errors',
ttl: '1d'
})
Unknown key: :ttl. Valid keys are: :start, :batch_size : {"ids":[358]}
我还尝试将TTL选项添加到批量导入作为选项(为实现此目的:https://www.elastic.co/guide/en/elasticsearch/reference/1.4/docs-bulk.html#bulk-ttl),但我无法使用该选项:
table#mytable {
display: table;
table-layout: fixed;
width: 100%;
}
table#mytable tr {
max-height:20px;
}
table#mytable tr td {
max-height:20px;
}
我对如何做到这一点有任何想法?