使用 man ascii 来查看 ASCII 表。

json格式输入到elasticsearch,如何转换一个字段为string?

Logstash | 作者 auroracxy | 发布于2016年05月12日 | 阅读数:7347

比如日志
{"release_time": "1998-01-01", "home_url": "http://www.777.com/show_page/id_001.html", "isVip": "", "channel": "777"}
{"release_time": "2009", "home_url": "http://www.666.com/show_page/id_002.html", "isVip": "true", "channel": "666"}
{"release_time": "", "home_url": "http://www.666.com/show_page/id_003.html", "isVip": "", "channel": "666"}
 
我需要将releas_time固定设置为string, isVip也为strint
我在filter中使用了 
    mutate {
        convert => { "rating" => "float" }
        convert => { "release_time" => "string" }
        convert => { "isVip" => "string" }
    }
 
logstash日志报错:
"error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse [release_time]", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"Invalid format: \"\""
 
 
curl -XGET http://localhost:9200/test-a-2016.05.12  看到
...
"release_time":{"type":"date","format":"strict_date_optional_time||epoch_millis"
已邀请:

三斗室 - ELK

赞同来自: auroracxy

自己PUT一个mapping上去。

flank

赞同来自: auroracxy

mapping设定后不能修改,建立一个alias;然后新建一个string类型的mapping,把旧的index指向这个新的index,再把数据迁移到新索引下。嫌麻烦就照1楼说的,新增一个mapping,往新的里面写。旧的不管~

要回复问题请先登录注册