elasticsearch mapping issue: failed to parse field

I have this mapping

PUT /mytest
{ "mappings":{ "properties": { "value": { "type": "object" } } }
}

When I insert this document

POST /mytest/_doc/4
{ "value": { "value": "test"}
}

I got the following error:

{ "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "failed to parse field [value.value] of type [long] in document with id '4'. Preview of field's value: 'test'" } ], "type": "mapper_parsing_exception", "reason": "failed to parse field [value.value] of type [long] in document with id '4'. Preview of field's value: 'test'", "caused_by": { "type": "illegal_argument_exception", "reason": "For input string: \"test\"" } }, "status": 400
}

I know the naming convention is bad, still, this is a valid JSON request, not sure why it doesn't allow it.

1 Answer

This error is telling you that you don't have a mapping for the property value within your value object property. The below example would property set the value.value property within your mytest index:

PUT mytest
{ "mappings": { "properties": { "value": { "type": "object", "properties": { "value": { "type": "text" } } } } }
}

However, I don't think that's what your intention was. As a best practice, try following the Elastic Common Schema (ECS) for naming your index properties.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like