如何更改现有索引中一个字段的映射? Elasticsearch

时间:2016-07-18 14:55:53

标签: elasticsearch

我有映射索引:

GET /warhammer/_mapping

给我:

{
   "warhammer": {
      "mappings": {
         "logs": {
            "properties": {
               "@timestamp": {
                  "type": "date",
                  "format": "dateOptionalTime"
               },
               "@version": {
                  "type": "string"
               },
               "HostName": {
                  "type": "string"
               },
               "boosters": {
                  "type": "long"
               },
               "device_model": {
                  "type": "string"
               },
               "build_type": {
                  "type": "string"
               }....
}

我需要将字段device_model的映射更改为not_analysed! 我试过了:

PUT /warhammer/_mapping
{
    "device_model": { "type": "string",
    "fields": { "raw":
    { "type": "string", "index": "not_analyzed" } } }
}

和此:

PUT /warhammer/_mapping
{
    "device_model": { 
        "type": "string", 
        "fields":
            { "raw": 
                { "type": "string", 
                    "index": "not_analyzed" } 
        } 
    }
}

但它给了我:

  {
   "error": "ActionRequestValidationException[Validation Failed: 1: mapping type is missing;]",
   "status": 400
  }

我做错了什么?求救!

1 个答案:

答案 0 :(得分:1)

PUT /warhammer/_mapping/logs
{
  "properties": {
    "device_model": {
      "type": "string",
      "fields": {
        "raw": {
          "type": "string",
          "index": "not_analyzed"
        }
      }
    }
  }
}