Got it

Failed to add Elasticsearch MapperParsingException[object mapping

Latest reply: May 18, 2022 00:57:24 2557 1 2 0 0

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.

  1. failure in bulk execution:

  2. [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!

  • x
  • convention:

olive.zhao
Admin Created May 18, 2022 00:57:24

Thanks for your sharing!
View more
  • x
  • convention:

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.
Information Protection Guide
Thanks for using Huawei Enterprise Support Community! We will help you learn how we collect, use, store and share your personal information and the rights you have in accordance with Privacy Policy and User Agreement.