Issue on creating index mapping

Hi, i would like to create the following structure with my index template:

    egress.bytes
    egress.test
    egress.test.delta
    egress.test.performance
    egress.test.state
    egress.test.state.performance.low
    egress.test.state.performance.high

i tried using the following api request to create the mapping:

    PUT testing_index_template_mapping/_mapping
    {
      "properties": {
        "egress": {
          "properties": {
            "bytes": {
              "type": "integer"
            },
            "test": {
              "properties": {
                "delta": {
                  "type": "integer"
                },
                "state": {
                  "properties": {
                    "performance": {
                      "properties": {
                        "high": {
                          "type": "integer"
                        },
                        "low": {
                          "type": "integer"
                        }
                      },
                      "type": "integer"
                    }
                  },
                  "type": "integer"
                }
              },
              "type": "integer"
            }
          }
        }
      }
    }

but elasticsearch keeps returning the following error:

    {
      "error" : {
        "root_cause" : [
          {
            "type" : "mapper_parsing_exception",
            "reason" : "Mapping definition for [test] has unsupported parameters:  [properties : {delta={type=integer}, state={type=integer, properties={performance={type=integer, properties={high={type=integer}, low={type=integer}}}}}}]"
          }
        ],
        "type" : "mapper_parsing_exception",
        "reason" : "Mapping definition for [test] has unsupported parameters:  [properties : {delta={type=integer}, state={type=integer, properties={performance={type=integer, properties={high={type=integer}, low={type=integer}}}}}}]"
      },
      "status" : 400
    }

I just cant get it to work. Do you hae any tips for me to fix the issue?

The egress.test field have properties under it so will be an object. It can therefore not also be of type integer. You can not have field names with dots.

So In short this should be correct, your objects as @Christian_Dahlqvist said can not have types. If you want a type that represents that object state / statues you need to add another field in the object and call it state or value or some additional field

    egress.bytes
    egress.test <<- Object
    egress.test.delta
    egress.test.state <<- Object
    egress.test.state.performance  <<- Object
    egress.test.state.performance.low
    egress.test.state.performance.high
PUT testing_index_template_mapping/_mapping
{
  "properties": {
    "egress": {
      "properties": {
        "bytes": {
          "type": "integer"
        },
        "test": {
          "properties": {
            "delta": {
              "type": "integer"
            },
            "state": {
              "properties": {
                "performance": {
                  "properties": {
                    "high": {
                      "type": "integer"
                    },
                    "low": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
2 Likes