Ttl with node js

I want to set ttl to a document using node js(ts) :
below is the code
private setTTL(indexName: string, indexType: string) {
console.log("*************index: "+indexName+" and type is : "+indexType);
console.log("config.api.header_info_ttl: "+config.api.header_info_ttl);
index: indexName,
type: indexType,
body: {
"header_info": {
'_ttl': {
"enabled": true,
'default': config.api.header_info_ttl
.then(function (result) {
console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&result', result)

but when I try to execute it below is the error I am getting:

(node:51812) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [mapper_parsing_exception] Root mapping definition has unsupported parameters:  [header_info : {_ttl={enabled=true, default=1m}}] :: {"path":"/api_connector_rs/_mapping/header_info_rs","query":{},"body":"{\"header_info\":{\"_ttl\":{\"enabled\":true,\"default\":\"1m\"}}}","statusCode":400,"response":"{\"error\":{\"root_cause\":[{\"type\":\"mapper_parsing_exception\",\"reason\":\"Root mapping definition has unsupported parameters:  [header_info : {_ttl={enabled=true, default=1m}}]\"}],\"type\":\"mapper_parsing_exception\",\"reason\":\"Root mapping definition has unsupported parameters:  [header_info : {_ttl={enabled=true, default=1m}}]\"},\"status\":400}"}

I am using ES version : 6.0.1

I read it somewhere it ttl is not supported after 2.4 versions, What is the alternate to delete a document in elastic search using node js


Indeed TTL is not supported anymore. If you to just delete a document then check this

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.