# Elastic search redefining mapping of an index

**URL:** <https://discuss.elastic.co/t/elastic-search-redefining-mapping-of-an-index/126931>\
**Category:** Elasticsearch\
**Created:** [April 5, 2018, 12:58pm UTC](https://discuss.elastic.co/t/elastic-search-redefining-mapping-of-an-index/126931 "2018-04-05T12:58:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ongun](https://avatars.discourse-cdn.com/v4/letter/o/b19c9b/32.png) [@Ongun](https://discuss.elastic.co/u/Ongun)\
**Post date:** [April 5, 2018, 12:58pm UTC](https://discuss.elastic.co/t/elastic-search-redefining-mapping-of-an-index/126931/1 "2018-04-05T12:58:14Z")

</div>

I have an index called `sql_session` on Elasticsearch and this index has some floating point data which is wrongly indexed as a **long** data type. I want to correct this, is it possible to do so with a command similar to the following command on the Kibana console or should I delete and recreate the entire index/index pattern?

```
PUT sql_session/_mapping/doc
{
  "properties": {
    "name": {
      "properties": {
        "price": { 
          "type": "float"
        }
      }
    },
  } 
}

```

The return of `GET sql_session/_mapping/doc` is as follows:

```
{
  "sql_session": {
    "mappings": {
      "doc": {
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "description": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "duration": {
            "type": "long"
          },
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "price": {
            "type": "long"
          },
          "processid": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "sessionid": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "starteruserid": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "statusid": {
            "type": "long"
          },
          "tags": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "username": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![Evesy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evesy/32/29520_2.png) [@Evesy](https://discuss.elastic.co/u/Evesy)\
**Post date:** [April 5, 2018, 2:34pm UTC](https://discuss.elastic.co/t/elastic-search-redefining-mapping-of-an-index/126931/2 "2018-04-05T14:34:43Z")

</div>

Hey Ongun,

If you want to change the mapping of a field in an existing index you'll have to use the reindex API: [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html). This blog post explains the process better than I can: [https://www.elastic.co/blog/changing-mapping-with-zero-downtime](https://www.elastic.co/blog/changing-mapping-with-zero-downtime)

If you don't care about the data then updating the template and then deleting the index will work, the new index will be created with the correct mapping.

Cheers,  
Mike

---

<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:** [May 3, 2018, 2:35pm UTC](https://discuss.elastic.co/t/elastic-search-redefining-mapping-of-an-index/126931/3 "2018-05-03T14:35:25Z")

</div>

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