[mapper_parsing_exception] when creating the same document with different type


(Tim Wong) #1

I am importing a document twice into the same index but different types. However, I got a [mapper_parsing_exception] when I import the document the second time.

Below are my steps.

  1. Create the template for the index.

    {
      "order": 0,
      "template": "stats-*",
      "settings": {
        "index": {
          "number_of_shards": "1",
          "number_of_replicas": "1",
          "refresh_interval": "5s"
        }
      },
      "mappings": {
        "_default_": {
          "include_in_all": false,
          "dynamic_templates": [
            {
              "metrics_fields": {
                "path_match": "metrics.*",
                "mapping": {
                  "scaling_factor": 100,
                  "type": "scaled_float"
                }
              }
            }
          ],
          "_all": {
            "norms": false,
            "enabled": true
          },
          "properties": {
            "@timestamp": {
              "type": "date"
            },
            "@version": {
              "type": "keyword"
            }
          }
        }
      },
      "aliases": {}
    }
    
  2. Import the document into type a. The import was successful.

    POST stats-demo/a
    {
      "@timestamp": "2017-04-19T03:40:04.000Z",
      "@version": "1",
      "metrics": {
        "blockout": 0,
        "memory": 569.2,
        "cpu": 1420.4,
        "blockin": 123.5,
        "netout": 0,
        "memlimit": 1024,
        "netin": 0
      }
    }
    
  3. Import the same document into type b of the same index. The following exception was thrown:

    {
      "error": {
        "root_cause": [
          {
            "type": "mapper_parsing_exception",
            "reason": "failed to parse"
          }
        ],
        "type": "mapper_parsing_exception",
        "reason": "failed to parse",
        "caused_by": {
          "type": "illegal_argument_exception",
          "reason": "Field [blockout] misses required parameter [scaling_factor]"
        }
      },
      "status": 400
    }
    

Below is the mapping of the stats-demo after the first successful import:

{
  "stats-demo": {
    "aliases": {},
    "mappings": {
      "_default_": {
        "include_in_all": false,
        "_all": {
          "enabled": true,
          "norms": false
        },
        "dynamic_templates": [
          {
            "metrics_fields": {
              "path_match": "metrics.*",
              "mapping": {
                "scaling_factor": 100,
                "type": "scaled_float"
              }
            }
          }
        ],
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "keyword"
          }
        }
      },
      "a": {
        "include_in_all": false,
        "_all": {
          "enabled": true,
          "norms": false
        },
        "dynamic_templates": [
          {
            "metrics_fields": {
              "path_match": "metrics.*",
              "mapping": {
                "scaling_factor": 100,
                "type": "scaled_float"
              }
            }
          }
        ],
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "keyword"
          },
          "metrics": {
            "properties": {
              "blockin": {
                "type": "scaled_float",
                "scaling_factor": 100
              },
              "blockout": {
                "type": "scaled_float",
                "scaling_factor": 100
              },
              "cpu": {
                "type": "scaled_float",
                "scaling_factor": 100
              },
              "memlimit": {
                "type": "scaled_float",
                "scaling_factor": 100
              },
              "memory": {
                "type": "scaled_float",
                "scaling_factor": 100
              },
              "netin": {
                "type": "scaled_float",
                "scaling_factor": 100
              },
              "netout": {
                "type": "scaled_float",
                "scaling_factor": 100
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "refresh_interval": "5s",
        "number_of_shards": "1",
        "provided_name": "stats-demo",
        "creation_date": "1492669920734",
        "number_of_replicas": "1",
        "uuid": "_kbN2j5sTBieLc08Zcg6vA",
        "version": {
          "created": "5020299"
        }
      }
    }
  }
}

I am confusing why the same document couldn't be imported into another type of the same index.

Thank you for any help. Any possible solution is appreciated!


(Mark Walkom) #2

You cannot do this as it's a collision. You will need to put it in a new index or think of a different structure.


(Tim Wong) #3

May I know how the collision happens? I thought that type is designed to store data with very similar data structure. I can actually import the same document twice if I am using the same type.

Thanks a lot!


(Mark Walkom) #4

Sorry, I don't know what I was thinking when I replied previously, but what I said is wrong!


(system) #5

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