varchar(128)
。我为此目的使用了logstash jdbc插件,但是当我启动docker映像时,我看到了很多警告消息,说org.elasticsearch.index.mapper.MapperParsingException: failed to parse field [status] of type [boolean] in document with id '34ZXb24BsfR1FhttyYWt'. Preview of field's value: 'Success'"
。但是,令我感到困惑的是,映射似乎是正确的:"status": { "type": "text", ... }
,并且数据似乎已成功提取。我什至尝试手动创建索引,然后在提取数据之前放置映射,但这也无济于事。
任何想法为什么?
添加更多信息:
表定义
CREATE TABLE records (
id int(11) NOT NULL AUTO_INCREMENT,
...
status varchar(128) NOT NULL DEFAULT '',
...
)
Elasticsearch映射
{
"properties": {
...
"status": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
...
}
数据示例
+-----------+-----------+
| id | status |
+-----------+-----------+
| 452172830 | success |
| 452172835 | other |
| 452172840 | success |
...
Elasticsearch映射模板更多信息
PUT /_template/records_template
{
"index_patterns": ["records"],
"mappings": {
"_source": {
"enabled": false
},
"properties": {
"status": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
Logstash conf
input {
jdbc {
tags => "records"
jdbc_connection_string => "jdbc:mysql://10.0.2.15:3306/esd"
jdbc_user => "dbuser"
jdbc_password => "dbpass"
schedule => "* * * * *"
jdbc_validate_connection => true
jdbc_paging_enabled => true
jdbc_page_size => 100000
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
statement => "select * from records order by id asc"
}
...
}
output {
if "records" in [tags] {
elasticsearch {
hosts => "elasticsearch:9200"
user => "elastic"
password => "changeme"
index => "records"
template_name => "records_template"
document_id => "%{id}"
}
}
...
我从此处在docker上使用ELK 7.4.1,我需要从MySQL数据库中提取数据。其中一张表的“状态”字段定义为varchar(128)。我为此使用了logstash jdbc插件...
select status as rd_status, ...
,则所有错误均消失了。不知道内部是否会丢失弹性搜索映射或logstash是否会尝试通过名称status
猜测数据类型(如果是后者,我会感到惊讶)