我在Elasticsearch中找到了_ttl
映射。我想知道如何将这个映射与tire
gem一起使用。代码片段受到高度赞赏。
答案 0 :(得分:1)
根本没有轮胎专家,但认为这样可以解决问题:
Tire.index 'index-with-ttl' do
delete
create mappings: {
document: {
_ttl: { enabled: true , default: "1d" },
properties: {
# properties goes here
}
}
}
refresh
end
答案 1 :(得分:0)
如果您没有使用ActiveModel集成,请使用@MarcusGranström回答
Tire.index 'index-with-ttl' do
delete
create mappings: {
document: {
_ttl: { enabled: true , default: "1d" },
properties: {
# properties goes here
}
}
}
refresh
end
如果您正在使用ActiveModel Integration
tire do
settings do
# Expiring the index after 30 days (_ttl parameter)
# http://www.elasticsearch.org/guide/reference/mapping/ttl-field/
mapping _ttl: { enabled: true, default: '30d' } do
# add the indexes here
end
end
end