Indexing JSON

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

For example, when I try to index this

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}

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.

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