Change a field type Kibana

Hi everyone,

I need to change a field type from "text" to "date" because I need to calculate the average time from a variable calculated inside my code. But when I try to change it, the option is not available.
image

I have looked for any solution and it seems that I have to make a query for it. I have try multiple options but I do not find the way.

If I make a " GET /default/_mapping ", this is what I get:

{
  "default" : {
    "mappings" : {
      "logEvent" : {
        "properties" : {
          "@timestamp" : {
            "type" : "date"
          },
          "Source" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "TiempoTransaccion" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "activityInfo" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "fileName" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "fingerprint" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "jobId" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "level" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "levelOrdinal" : {
            "type" : "long"
          },
          "logType" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "machineId" : {
            "type" : "long"
          },
          "machineName" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "message" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "processName" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "processVersion" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "processingExceptionReason" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "processingExceptionType" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "queueItemPriority" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "queueItemReviewStatus" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "queueName" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "rawMessage" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "robotName" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "tenantKey" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "timeStamp" : {
            "type" : "date"
          },
          "totalExecutionTime" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "totalExecutionTimeInSeconds" : {
            "type" : "long"
          }
        }
      }
    }
  }
}

The field I want to change is "TiempoTransaccion" from texto to date, and the query I have used is this one:

PUT /_default/_mapping
{
"mappings": {
"logEvent": {
"properties": {
"TiempoTransaccion": {
"type": "date"
}
}
}
}
}

But it does not work.

Please, can you help me to change the field type? I getting mad!

Thank you so much!!

Your index name is default, but your mapping update was to _default. You're correct in that you need to change the mapping - then in Kibana you can refresh the index pattern. What error are you seeing now with that command?

With this query:

PUT /default/_mapping
{
  "mappings": {
    "logEvent": {
      "properties": {
        "TiempoTransaccion": {
          "type": "date"
        }
      }
    }
  }
}

I am getting this reponse:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
},
"status": 400
}

mappings should be properties

PUT /default/_mapping
{
  "properties": {
    "logEvent": {
      "properties": {
        "TiempoTransaccion": {
          "type": "date"
        }
      }
    }
  }
}

The same error continue..

{
  "error": {
    "root_cause": [
      {
        "type": "action_request_validation_exception",
        "reason": "Validation Failed: 1: mapping type is missing;"
      }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: mapping type is missing;"
  },
  "status": 400
}

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