# Ingestion doc to index template

**URL:** <https://discuss.elastic.co/t/ingestion-doc-to-index-template/270093>\
**Category:** Kibana\
**Created:** [April 14, 2021, 9:35am UTC](https://discuss.elastic.co/t/ingestion-doc-to-index-template/270093 "2021-04-14T09:35:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![accateo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/accateo/32/85332_2.png) [@accateo](https://discuss.elastic.co/u/accateo)\
**Post date:** [April 14, 2021, 9:35am UTC](https://discuss.elastic.co/t/ingestion-doc-to-index-template/270093/1 "2021-04-14T09:35:09Z")

</div>

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

```auto
{
      "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:

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![azasypkin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/azasypkin/32/42216_2.png) [@azasypkin](https://discuss.elastic.co/u/azasypkin)\
**Post date:** [April 14, 2021, 9:59am UTC](https://discuss.elastic.co/t/ingestion-doc-to-index-template/270093/2 "2021-04-14T09:59:49Z")

</div>

> [@accateo](#):
>
> Any idea? If I don't use the template, it works all without problem.

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

---

<div class="post-metadata">

**Author:** ![accateo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/accateo/32/85332_2.png) [@accateo](https://discuss.elastic.co/u/accateo)\
**Post date:** [April 14, 2021, 10:21am UTC](https://discuss.elastic.co/t/ingestion-doc-to-index-template/270093/3 "2021-04-14T10:21:50Z")

</div>

Yes, I compared.

With a different index name:

```auto
{
  "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"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 12, 2021, 10:22am UTC](https://discuss.elastic.co/t/ingestion-doc-to-index-template/270093/4 "2021-05-12T10:22:15Z")

</div>

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