# Can't map all fields to text type

**URL:** <https://discuss.elastic.co/t/cant-map-all-fields-to-text-type/91947>\
**Category:** Elasticsearch\
**Created:** [July 5, 2017, 3:31pm UTC](https://discuss.elastic.co/t/cant-map-all-fields-to-text-type/91947 "2017-07-05T15:31:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeThomsen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikethomsen/32/19378_2.png) [@MikeThomsen](https://discuss.elastic.co/u/MikeThomsen)\
**Post date:** [July 5, 2017, 3:31pm UTC](https://discuss.elastic.co/t/cant-map-all-fields-to-text-type/91947/1 "2017-07-05T15:31:35Z")

</div>

I am trying to map all fields as `text`. Based on the docs, this should work, but it doesn't:

```
PUT my_type
{
  "mappings": {
    "my_type": {
      "dynamic_templates": [
        {
          "longs_as_strings": {
            "match_mapping_type": "*",
            "match": "*",
            "mapping": {
              "type": "text"
            }
          }
        }
      ]
    }
  }
}

PUT my_type/my_type/1
{
  "intfield": 5
}

GET my_type/_search

```

Results in:

```
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "my_type",
        "_type": "my_type",
        "_id": "1",
        "_score": 1,
        "_source": {
          "intfield": 5
        }
      }
    ]
  }
}
```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 5, 2017, 3:37pm UTC](https://discuss.elastic.co/t/cant-map-all-fields-to-text-type/91947/2 "2017-07-05T15:37:05Z")

</div>

Check what the mapping looks like by runniung `GET /my_type/_mapping/my_type`. Elasticsearch will not modify the source document, but that does not mean it is not correctly mapped.

---

<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:** [August 2, 2017, 3:37pm UTC](https://discuss.elastic.co/t/cant-map-all-fields-to-text-type/91947/3 "2017-08-02T15:37:32Z")

</div>

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