Environment related
- Elasticsearch-7.14.2
- logstash-7.14.2
- kibana-7.14.2
DELETE tagsjons
PUT tagsjons
{
"mappings": {
"properties": {
"title":{
"type":"text"
},
"tags": {
"type": "nested",
"properties": {
"group_name": {
"type": "keyword"
},
"tag_name": {
"type": "keyword"
},
"tag_id": {
"type": "keyword"
},
"type": {
"type": "long"
}
}
}
}
}
}
}
}
The Kibana console is plugged in without problems
PUT tagsjons/_doc/2
{
"title":"json object",
"tags": [
{"group_name":"group name","tag_name":"is ok","tag_id":"mUV-wdjnVd6tp6n7Q","type":1},{"group_name":"group name 2","tag_name":"not ok","tag_id":"qZ2Sba5c5R0bDw","type":1},{"group_name":"three","tag_name":"C","tag_id":"shUza_u11JgjBEnzA","type":1},{"group_name":"ss","tag_name":"okkkk)","tag_id":"eQo4KvOMRtQ","type":1}
]
}
But there is a problem if it is imported through logstsh
object mapping for [tags] tried to parse field [tags] as object, but found a concrete value
The main part of the error report
...
"tags"=>"[{\"group_name\":\"22\",\"tag_name\":\"eee\",\"type\":1},{\"group_name\":\"dsfsf\",\"tag_name\":\"sfsfsd\",\"type\":2}]", "dialout_rule_id"=>0,
...
, :response=>{"index"=>{"_index"=>"test-index", "_type"=>"_doc", "_id"=>"1018", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"object mapping for [tags] tried to parse field [tags] as object, but found a concrete value"}}}}
It seems that this value is wrapped in double quotation marks, but at present, beginners can't find a good solution
--
logstash config like this
input {
jdbc {
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://192.168.0.2:3306/scrm_local?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull"
jdbc_user => test
jdbc_password => test123
use_column_value => true
jdbc_default_timezone => "Asia/Shanghai"
tracking_column => "id"
tracking_column_type => "numeric"
record_last_run => true
last_run_metadata_path => "last.txt"
statement => "SELECT * FROM example where id >:sql_last_value;"
schedule => " * * * * *"
}
}
output {
elasticsearch {
document_id => "%{id}"
document_type => "_doc"
index => "test-index"
hosts => ["http://xxx:9200","http://xx:9200"]
}
stdout{
codec => rubydebug
}
}