Overriding mapping from text to object

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.

{
  "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:

{
  "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:

{
  "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.

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