Several types as values to same key

I have jenkins logs in a json format. (taken with the API)
the logs have different types of value to the same key:
and more. when try to upload them using elastic-python, I got this error:
BadRequestError(400, 'illegal_argument_exception', 'mapper [actions.parameters.value] cannot be changed from type [text] to [boolean]')

I do some digging, but didn't find a solution for that.
any idea what I can do to upload the json successfully?


You need to explicitly create a mapping for your index as explained in the documentation.

The issue here is that you didn't explicitly mapped the fields, so Elasticsearch will try to map it according to the first value it receives for any field, in your case it received a value of true or false and then mapped the field as a boolean field, but you have other documents where the value of this field can be something else.

You will need to map the field as keyword since it can has values that are not only true or false.

1 Like

there is a way to do that not manually? my json file is huge.

You nee to have the correct mapping for every field, however you can use a dynamic template that will, for example, map every string that elasticsearch receives as a keyword field.

Check this documentation

thanks! that's very helpful!

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