elasticsearch mapping issue: failed to parse field

21,859

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.

Share:
21,859

Related videos on Youtube

user342673
Author by

user342673

Updated on January 11, 2020

Comments

  • user342673
    user342673 over 4 years

    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.