winston-elasticsearch icon indicating copy to clipboard operation
winston-elasticsearch copied to clipboard

ensureIndexTemplate and indexTemplate not working

Open yacineBR opened this issue 2 years ago • 11 comments

I want to add mappings to the index using indexTemplate . i set ensureIndexTemplate to true and i put indexTemplate: { mappings: { properties: { co: { index: true, type: "keyword", }, age: { type: "integer", }, }, }, } but nothing happened.

yacineBR avatar Sep 22 '21 16:09 yacineBR

I have the same problem.

ivan901229 avatar Sep 23 '21 03:09 ivan901229

same issue

asmafakhfakh avatar Sep 26 '21 14:09 asmafakhfakh

same problem :(

zeinMch avatar Sep 26 '21 14:09 zeinMch

I have the same issue

SondessLarbi avatar Sep 26 '21 15:09 SondessLarbi

are you using data streams (dataStream: true ) and what means "but nothing happened."? Does that mean the template is not created?

vanthome avatar Oct 04 '21 10:10 vanthome

are you using data streams (dataStream: true ) and what means "but nothing happened."? Does that mean the template is not created?

Yes the template is not created, I'm not using data streams .

yacineBR avatar Oct 05 '21 08:10 yacineBR

Which version of ES are you running?

I am trying to upgrade my plugin version, and I just found out 0.14.0 introduced a breaking change that only works on ES 7.8+. The new index template was introduced on ES 7.8, and those running 7.7- are bound to the legacy index template API calls.

thiago-negri avatar Oct 21 '21 12:10 thiago-negri

I have added more debug code for this. So please try with the latest release and enable debug output.

vanthome avatar Dec 08 '21 09:12 vanthome

Can someone follow up on this? Is this an issue with the ES version you are running?

vanthome avatar May 14 '22 22:05 vanthome

I have the same issue with current 0.17.2 (@elastic/elasticsearch 8.8.1, running with ES 8.7.0) Tracking down in debug, I noticed that within the bulk_writer.js:206:

  debug('Checking tpl name', tmplCheckMessage);
  thiz.client.indices.existsIndexTemplate(tmplCheckMessage).then(
    (res) => {
      if (res.statusCode && res.statusCode === 404) {

For some reason res is false, so the template isn't created. Current workaround is to manually check & create the template but please fix this :/

ishtanzar avatar Jul 18 '23 08:07 ishtanzar

@vanthome the issue happens because to get statusCode from existsIndexTemplate you have to pass the 2nd parameter with enabled meta: existsIndexTemplate(tmplCheckMessage, { meta: true })

lenchv avatar Sep 12 '23 15:09 lenchv