Mapping being ignored?

ES 2.0
I've been trying to apply mapping to an index ( empty index ) but it doesn't seem to persist.

I've added sync.json to /config/mappings/_default

it contains:

  {
  "sync" :{
    "_timestamp" : {
      "enabled" : true,
      "path" : "time",
      "ignore_missing" : true,
      "store":true
    },
    "properties": {
      "channel": {
        "type": "string",
        "store" : true
      },
      "id": {
        "type": "integer"
      },
      "level": {
        "type": "integer",
        "store" : true
      },
      "message": {
        "type": "string"
      },
      "source": {
        "type": "string"
      },
      "time": {
        "type": "date"
      },
      "userid": {
        "type": "integer",
        "store" : true
      }
    }

  }
}

I then add an index from sense with:

PUT my_index

when I do GET my_index/sync/_mapping I get {}

Using the PHP API I add documents to my_index/sync

I can query them :

GET my_index/_search
{
  "query": {
    "match_all": {}
  }
}

and get results like this:

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "my_index",
        "_type": "sync",
        "_id": "AVC0jcBJFw6NV60SFjbM",
        "_score": 1,
        "_source": {
          "id": "12435",
          "channel": "abc",
          "level": "200",
          "source": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          "message": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
          "userid": "12345",
          "time": 1403283202000
        }
      }]}
      }

When I do GET my_index/sync/_mapping i get

{
  "my_type": {
    "mappings": {
      "sync": {
        "properties": {
          "channel": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "level": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "time": {
            "type": "long"
          },
          "userid": {
            "type": "string"
          }
        }
      }
    }
  }
}

So the mapping I put in _default is 'ignored' and ES just uses its own default mappings. The same behavior happens when I PUT the mapping instead of using the config/mappings/default/sync.json file.
Also kibana recognised that an index of my_index exists but cannot see any time fields in settings
>configure_an_index_pattern,

Can anyone point me in the right direction please?

Sounds like this: https://www.elastic.co/guide/en/elasticsearch/reference/2.0/_mapping_changes.html#_mappings_in_config_files_not_supported

1 Like

You're right - applied the new mapping and all is working finally. Many thanks

I have a similar question. I have a template under config/templates that was picked up automatically in elasticsearch 1.7.2. Now it's ignored. On startup, I see elastic search showing templates[]. I noticed that I need to add it to my logstash.config now, so I did add the filename (template_name => "template_error_log.json"). I assumed the directory would default to elasticsearchxxx/config/templates based on the documentation. When I ask the system what templates its aware of:
curl -XGET localhost:9200/_template
I just gives me the default, "logstash-*" and I can't seem to override it with the one I was using before.
I do want continue to be able to define it in a file, not through an API.
Any suggestions?

Thanks.

I think the option is template not template_name. Might want to try using a full path to simplify your debugging.