3

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 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.