# Overriding mapping from text to object

**URL:** <https://discuss.elastic.co/t/overriding-mapping-from-text-to-object/150329>\
**Category:** Elasticsearch\
**Created:** [September 28, 2018, 11:22am UTC](https://discuss.elastic.co/t/overriding-mapping-from-text-to-object/150329 "2018-09-28T11:22:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aliok/32/35982_2.png) [@aliok](https://discuss.elastic.co/u/aliok)\
**Post date:** [September 28, 2018, 11:22am UTC](https://discuss.elastic.co/t/overriding-mapping-from-text-to-object/150329/1 "2018-09-28T11:22:49Z")

</div>

I am trying to override a mapping for a field.

There is a default index template (which I can't change) and I am overriding it with a custom one.

The default index has a mapping for "message" field as text, but I need to make it treated like an object and make its fields indexable/searchable.

This is the default index template, with order 10.

```auto
{
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "message_field": {
            "mapping": {
              "index": true,
              "norms": false,
              "type": "text"
            },
            "match": "message",
            "match_mapping_type": "string"
          }
        },
        ...
      ],
      "properties": {
        "message": {
          "doc_values": false,
          "index": true,
          "norms": false,
          "type": "text"
        },
        ...
      }
    }
  },
  "order": 10,
  "template": "project.*"
}

```

And here's my override:

```auto
{
  "template" : "project.*",
  "order" : 100,
  "dynamic_templates": [
    {
      "message_field": {
        "mapping": {
          "type": "object"
        },
        "match": "message"
      }
    }
  ],
  "mappings": {
    "message": {
      "enabled": true,
      "properties": {
        "tag": {"type": "string", "index": "not_analyzed"},
        "requestId": {"type": "integer"},
        ...
      }
    }
  }
}

```

This works nice, but I end up defining all fields (tag, requestId, ...) in the "message" object.

Is there a way to make all the fields in the "message" object indexable/searchable?

Here's a sample document:

```auto
{
  "level": "30",
  ...
  "kubernetes": {
    "container_name": "data-sync-server",
    "namespace_name": "alitest03",
    ...
  },
  "message": {
    "tag": "AUDIT",
    "requestId": 1234,
    ...
    },
  }
  ...
}

```

Tried lots of things, but I can't make it work.

I am using ElasticSearch version 2.4.4.

---

<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:** [October 26, 2018, 11:23am UTC](https://discuss.elastic.co/t/overriding-mapping-from-text-to-object/150329/2 "2018-10-26T11:23:00Z")

</div>

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