Hello all,
this case mainly talks about "Failed to add Elasticsearch MapperParsingException[object mapping for [] tried to parse field [null] as an object but found a concrete value."
When developing an Elasticsearch demo, I found this error. In my demo, a crawler crawled some website information and then used Elasticsearch to store it. The mapping definition type of a field was objcet. Because it is an array, but Mapping cannot define an array, an object type is defined. As a result, the mapping is successfully created, but the data fails to be added.
Here's about failure in bulk execution:
Failed to add Elasticsearch MapperParsingException[object mapping for [] tried to parse field [null] as object, but found a concrete value.
This section describes the troubleshooting process and result.
My Mapping:
{
"mappings": {
"site_type1": {
"_ttl": {
"enabled": false
},
"properties": {
"server_address": {
"index": "not_analyzed",
"type": "string"
},
"baidu_suoyin": {
"type": "long"
},
"baidu_keys": {
"type": "long"
},
"beian_title": {
"index": "not_analyzed",
"type": "string"
},
"domain_server": {
"index": "not_analyzed",
"type": "string"
},
"domain_service": {
"index": "not_analyzed",
"type": "string"
},
"beian_index": {
"index": "not_analyzed",
"type": "string"
},
"br": {
"type": "long"
},
"city": {
"type": "object"
},
"qihu_shoulu": {
"type": "long"
},
"title": {
"type": "string"
},
"baidu_fanlian": {
"type": "long"
},
"baidu_pv": {
"type": "long"
},
"beian_type": {
"index": "not_analyzed",
"type": "string"
},
"server_ip": {
"type": "string"
},
"description": {
"type": "string"
},
"province": {
"type": "object"
},
"domain": {
"index": "not_analyzed",
"type": "string"
},
"sougou_fanlian": {
"type": "long"
},
"beian_number_no": {
"index": "not_analyzed",
"type": "string"
},
"beian_number": {
"index": "not_analyzed",
"type": "string"
},
"tags": {
"type": "object"
},
"qihu_fanlian": {
"type": "long"
},
"keywords": {
"type": "string"
},
"beian_name": {
"index": "not_analyzed",
"type": "string"
},
"baidu_shoulu": {
"type": "long"
},
"sr": {
"type": "long"
},
"alexa_pv": {
"type": "long"
},
"image": {
"type": "object"
},
"domain_begin_date": {
"index": "not_analyzed",
"type": "string"
},
"baidu_yue_shoulu": {
"type": "long"
},
"sougou_shoulu": {
"type": "long"
},
"url": {
"index": "not_analyzed",
"type": "string"
},
"server_type": {
"index": "not_analyzed",
"type": "string"
},
"server_timeout": {
"type": "long"
},
"google_fanlian": {
"type": "long"
},
"google_shoulu": {
"type": "long"
},
"update_time": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"domain_end_date": {
"index": "not_analyzed",
"type": "string"
},
"alexa_top": {
"type": "long"
},
"site_type": {
"type": "object"
},
"server_html_type": {
"index": "not_analyzed",
"type": "string"
},
"pr": {
"type": "long"
},
"baidu_zhou_shoulu": {
"type": "long"
}
}
}
}
}
An error is reported when data is added.
failure in bulk execution:
[0]: index [site_index1], type [site_type1], id [https://www.sojson.com], message [MapperParsingException[object mapping for [image] tried to parse field [null] as object, but found a concrete value]]
It is clear that Mapping does not match the stored data type.
"image": {
"type": "object"
}
I started to check whether the stored values were null and found that no values were null.
In fact, it's a mistake. The simplest method is to create an index instead of creating a mapping. Check the type of field in adaptive mapping. So what type do you create?
I used adaptive types and found that this array was of type string, so I defined it as string, and I solved the error.
Any solutions will be appreciated!