是时候用 ES 拯救发际线啦

elasticsearch 修改字段类型

Elasticsearch | 作者 zriplj | 发布于2020年01月13日 | 阅读数:6408

fping_log索引自动创建后
{
"fping_log": {
"aliases": {},
"mappings": {
"doc": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"delay": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"localhost": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"message": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"remotehost": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"time": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
},
"settings": {
"index": {
"creation_date": "1578896819804",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "ZhR0-OmyTb2U4y4flvMkuA",
"version": {
"created": "6020499"
},
"provided_name": "fping_log"
}
}
}
}

delay的字段类型是text,现在要修改成float,如何修改呢?我把索引删除后,都没法修改。索引数据不重要!!
已邀请:

zriplj

赞同来自:

1.png

设置mapping报错

Charele - Cisco4321

赞同来自:

把索引删除掉再建索引,把其中的mapping改成你需要的类型就可以了。

zriplj

赞同来自:

我的es 6.2的版本,下面代码亲测通过!
PUT fping_log
{
    "aliases": {},
    "mappings": {
      "doc": {
        "properties": {
          "delay": {
            "type": "float"
          },
          "localhost": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "message": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "remotehost": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "time": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "number_of_shards": "5",
        "number_of_replicas": "1"
      }
    }
}

- Elasticsearch,php

赞同来自:

用新的mapping创建一个索引,然后用logstash或者reindex同步数据

要回复问题请先登录注册