# Change a field type Kibana

**URL:** <https://discuss.elastic.co/t/change-a-field-type-kibana/206984>\
**Category:** Kibana\
**Created:** [November 7, 2019, 3:57pm UTC](https://discuss.elastic.co/t/change-a-field-type-kibana/206984 "2019-11-07T15:57:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajg](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@ajg](https://discuss.elastic.co/u/ajg)\
**Post date:** [November 7, 2019, 3:57pm UTC](https://discuss.elastic.co/t/change-a-field-type-kibana/206984/1 "2019-11-07T15:57:44Z")

</div>

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](https://us1.discourse-cdn.com/elastic/original/3X/c/c/ccdcd489cbd06cdfa5d332f8af96643593e4d070.png)

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!!

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [November 7, 2019, 4:22pm UTC](https://discuss.elastic.co/t/change-a-field-type-kibana/206984/2 "2019-11-07T16:22:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ajg](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@ajg](https://discuss.elastic.co/u/ajg)\
**Post date:** [November 7, 2019, 4:36pm UTC](https://discuss.elastic.co/t/change-a-field-type-kibana/206984/3 "2019-11-07T16:36:42Z")

</div>

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  
}

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [November 7, 2019, 6:59pm UTC](https://discuss.elastic.co/t/change-a-field-type-kibana/206984/4 "2019-11-07T18:59:00Z")

</div>

`mappings` should be `properties`

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

```

---

<div class="post-metadata">

**Author:** ![ajg](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@ajg](https://discuss.elastic.co/u/ajg)\
**Post date:** [November 7, 2019, 7:13pm UTC](https://discuss.elastic.co/t/change-a-field-type-kibana/206984/5 "2019-11-07T19:13:20Z")

</div>

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
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 5, 2019, 7:13pm UTC](https://discuss.elastic.co/t/change-a-field-type-kibana/206984/6 "2019-12-05T19:13:23Z")

</div>

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