Reputation: 7237
So i have an existing index. I close it to updateSettings and then reopen.
client.indices.putSettings({
index: 'myindex',
type: 'mytype',
body: {
'_ttl': {
"enabled" : true,
'default': '1m'
}
}
})
.then(function (result) {
console.log('result', result)
})
And then i create a new document to see if ttl is actually working but it doesn't work.
What i see from the index
Any idea on what i did wrong?
Upvotes: 0
Views: 211
Reputation: 217304
The _ttl
shall be set on the mapping type directly and not on the index so you want to use putMapping
instead of putSettings
.
client.indices.putMapping({
index: 'myindex',
type: 'mytype',
body: {
'mytype': {
'_ttl': {
"enabled" : true,
'default': '1m'
}
}
}
})
.then(function (result) {
console.log('result', result)
})
It is the equivalent of this REST call:
curl -XPUT 'http://localhost:9200/myindex/_mapping/mytype' -d '{
"mytype": {
"_ttl": {
"enabled": true, "default": "1m"
}
}
}'
Upvotes: 1