Reputation: 2093
I found the _ttl
mapping in Elasticsearch. I wonder how can I use this mapping with tire
gem. Code snippets are highly appreciated.
Upvotes: 1
Views: 225
Reputation: 2093
If you're not using the ActiveModel Integration, use @Marcus Granström answer
Tire.index 'index-with-ttl' do
delete
create mappings: {
document: {
_ttl: { enabled: true , default: "1d" },
properties: {
# properties goes here
}
}
}
refresh
end
If you're using 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
Upvotes: 0
Reputation: 17964
No Tire expert at all but think this will do the trick:
Tire.index 'index-with-ttl' do
delete
create mappings: {
document: {
_ttl: { enabled: true , default: "1d" },
properties: {
# properties goes here
}
}
}
refresh
end
Upvotes: 1