简体   繁体   中英

logstash input jdbc take mysql tinyint 0/1 as boolean true/false

In mysql table, has a tinyint type like this, which just store 0 or 1 value like is_mel:1 .

is_mel | tinyint(1)

In Elasticsearch index mapping config is_mel as integer.

But from the logstash log, it show it parse the is_mel as boolean value true or false like "is_mel":true , which will lead to below error,

"type"=>"mapper_parsing_exception",
"reason"=>"failed to parse field [is_mel] of type [integer] in document with id '392289'. Preview of field's value: 'true'"

It's actually a feature, not a bug :-)

You can append tinyInt1isBit=false to your JDBC URL to disable that behavior

jdbc.url=jdbc:mysql://127.0.0.1:3306/testdb?tinyInt1isBit=false
                                                    ^
                                                    |
                                                 add this

Link to the related MySQL doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM