# Illegal\_argument\_exception

**URL:** <https://discuss.elastic.co/t/illegal-argument-exception/125622>\
**Category:** Elasticsearch\
**Created:** [March 26, 2018, 1:55pm UTC](https://discuss.elastic.co/t/illegal-argument-exception/125622 "2018-03-26T13:55:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchannon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jchannon/32/23280_2.png) [@jchannon](https://discuss.elastic.co/u/jchannon)\
**Post date:** [March 26, 2018, 1:55pm UTC](https://discuss.elastic.co/t/illegal-argument-exception/125622/1 "2018-03-26T13:55:36Z")

</div>

I'm trying to index the below structure via fluentd

We have no indexes so this is the first document.

When sending it to Elastic we get

`2018-03-26 13:51:16 +0000 [error]: #0 Could not push log to Elasticsearch: {"took"=>132, "errors"=>true, "items"=>[{"index"=>{"_index"=>"fluentd-20180326", "_type"=>"access_log", "_id"=>"Ng2TYmIBuv17HTvizvlW", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper [Exceptions] of different type, current_type [text], merged_type [long]"}}}]}`

If our structure doesn't contain the Exception property all is indexed fine

Anyone know why we get this error from Elasticsearch?

```auto
[
  "My.SampleApp",
  1522072295,
  {
    "TimeStamp": [
      636576726957471700,
      60
    ],
    "Ticks": 636576690957471700,
    "MsgTmpl": "{@info}",
    "Level": "Error",
    "Exceptions": [
      [
        0,
        null,
        -2147467261,
        "Ooh it broke",
        "sample",
        " at sample.Program.DoSomethingThatThrows(Logger log)"
      ],
      [
        1,
        null,
        -2147024809,
        "Busted",
        null,
        ""
      ]
    ],
    "info": "LogMessage { RequestId: \"239423049FL\", Component: \"Startup\", Method: \"Configure\", Message: \"There has been an error\" }"
  }
]

```

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [March 27, 2018, 4:57am UTC](https://discuss.elastic.co/t/illegal-argument-exception/125622/2 "2018-03-27T04:57:25Z")

</div>

Sounds like Elasticsearch has inferred the mapping for the `Exceptions` field to be a `long`, based upon the first value that it has seen.

Looking at the values in the `Exceptions` array, the common type to use here would be either [`text`](https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html) or  
[`keyword`](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html) (or both, with a [`multi_field` mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html)), and let Elasticsearch coerce non-string JSON types to string when indexing.

---

<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:** [April 24, 2018, 4:57am UTC](https://discuss.elastic.co/t/illegal-argument-exception/125622/3 "2018-04-24T04:57:54Z")

</div>

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