# Indexing JSON

**URL:** <https://discuss.elastic.co/t/indexing-json/132329>\
**Category:** Elasticsearch\
**Created:** [May 17, 2018, 12:21pm UTC](https://discuss.elastic.co/t/indexing-json/132329 "2018-05-17T12:21:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![astropanic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/astropanic/32/20726_2.png) [@astropanic](https://discuss.elastic.co/u/astropanic)\
**Post date:** [May 17, 2018, 12:21pm UTC](https://discuss.elastic.co/t/indexing-json/132329/1 "2018-05-17T12:21:16Z")

</div>

How I should proceed to index JSON documents from Lighthouse into Elasticsearch?

For example, when I try to index [this](https://gist.github.com/astropanic/5148ba05c67885316883d5015e7c14aa)

via

```
curl -XPOST -H "Content-Type: application/json" 'http://myhost.com:9200/lighthouse/measurement' -d @index.report.json

```

I'm getting:

> {"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"mapper [audits.network-requests.details.items.text] of different type, current\_type [long], merged\_type [text]"}],"type":"illegal\_argument\_exception","reason":"mapper [audits.network-requests.details.items.text] of different type, current\_type [long], merged\_type [text]"},"status":400}

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 17, 2018, 3:39pm UTC](https://discuss.elastic.co/t/indexing-json/132329/2 "2018-05-17T15:39:00Z")

</div>

It looks like the field "audits.network-requests.details.items.text" was already indexed in Elasticsearch as a numeric `long`, but another document tried to index a string value. This can happen with auto-mapping which sees a number as the first value, even though the field is a string.

The best way to fix this is just to setup an explicit mapping on the index before starting to ingest documents. That way you can control the types of all the different fields.

---

<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:** [June 14, 2018, 3:48pm UTC](https://discuss.elastic.co/t/indexing-json/132329/3 "2018-06-14T15:48:47Z")

</div>

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