Ingestion doc to index template

Hi,
I've created a index template in Kibana:

{
      "properties": {
        "date": {
          "type": "date"
        },
        "formatDate": {
          "type": "text"
        },
        "temp": {
          "type": "long"
        },
        "busErr": {
          "type": "long"
        },
        "deviceId": {
          "type": "text"
        },
        "version": {
          "type": "double"
        },
        "uptime": {
          "type": "double"
        },
        "avgLoad": {
          "type": "long"
        },
        "diskFree": {
          "type": "long"
        }
      }
}

and I tried to ingest doc via NodeJS Application in this way:

var new_j = {"deviceId" : "XXX", "version": version, "uptime" : uptime, "busErr" : busErr, "avgLoad" : avgLoad, "temp" : temp, "diskFree" : diskFree, "formatDate" : formatDate(), "date" : new Date() };

client.index({
                             index: 'device_data_bridgenuzoo',
                             type: 'telemetry',
                             body: new_j
                        }), (err, resp, status) => {}

but I have this error:

UnhandledPromiseRejectionWarning: ResponseError: illegal_argument_exception
      at onBody (/home/rob/elasticData/node_modules/@elastic/elasticsearch/lib/Transport.js:333:23)

Any idea? If I don't use the template, it works all without problem.
Thanks

When you don't use template, what mapping is created when you index this document? Have you compared it with your template and noticed any difference?

Best,
Oleg

1 Like

Yes, I compared.

With a different index name:

{
  "mappings": {
    "telemetry": {
      "properties": {
        "avgLoad": {
          "type": "long"
        },
        "busErr": {
          "type": "long"
        },
        "date": {
          "type": "date"
        },
        "deviceId": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "diskFree": {
          "type": "long"
        },
        "formatDate": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "temp": {
          "type": "long"
        },
        "uptime": {
          "type": "long"
        },
        "version": {
          "type": "float"
        }
      }
    }
  }
}

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