当前位置: 首页 > 知识库问答 >
问题:

如何解决创建索引时出现的“无法解析要映射的内容”错误?

孔征
2023-03-14

我得到一个错误。

错误:

"{"错误":{"root_cause":[{"type":"parse_exception","原因":"未能解析内容映射"}],"type":"parse_exception","原因":"未能解析内容映射","caused_by":{"type":"json_parse_exception","原因":"意外字符('s'(代码115)):在试图创建索引时,期望双引号在[Source:org.elasticsearch.transport.netty4.ByteBufStreamInput@38a4cd00; line: 2, list: 3]"}},"state": 400}"错误处开始字段名\n

代码:

{
  "settings" : {
        "number_of_shards" : 1,
        "number_of_replicas" : 1
    },
   "mappings": {
             "properties": {
        "anonymous": {"type": "boolean"},
        "content_text_form": {"type": "text"},
        "details": {"type": "text"},
        "language": {"type": "keyword"},
        "no_of_comments": {"type": "long"},
        "up_votes": {"type": "long"},
        "down_votes": {"type": "long"},
        "no_of_views": {"type": "long"},
        "no_of_impressions": {"type": "long"},
        "short_id": {"type": "keyword"},
        "no_of_reposts": {"type": "long"},
        "createdAt": {"type": "date"},
        "updatedAt": {"type": "date"},
        "re_post_date": {"type": "date"},
        "media_urls": {
                        "properties": {
                          "url": {"type": "keyword"},
                          "type": {"type": "keyword"},
                          "uploadedOn": {"type": "date"},
                          "description": {"type": "text"},
                          "thumbnail": {"type": "text"},
                          "file_type": {"type": "keyword"},
                          "dimensions": {
                            "properties": {
                              "type": {
                                "properties": {
                                  "height": {"type": "long"},
                                  "width": {"type": "long"},
                                  "aspect_ratio":{"type":"long"}
                                },
                              "required": {"type": "boolean"}
                              }
                            }}
                          }
                          },
      "tags": {"type": "keyword"},
         "tag_positions": {
                          "properties": {
                            "tag": {"type": "keyword"},
                            "tag_start": {"type": "long"},
                            "tag_end": {"type": "long"}}},
          "source": {
          "properties": {
            "title" : {"type": "text"},
            "description": {"type": "text"},
            "media_type": {"type": "text"},
            "url": {"type": "text"}
          }
        },
           "moderation": {
          "properties": {
            "done": {"type":"boolean"}
          }
        }
       }
     }
}

共有1个答案

董琦
2023-03-14

我不确定您使用的是哪个版本的Elasticsearch,但我使用的是6.7,这是经过两次修改后运行的版本

1) I added "_doc"
2) I moved `"required": { "type": "boolean"}`  to one curly below ... look at it and it will make sense

这是对我有用的地图

  PUT so_test6
   {
      "settings" : {
         "number_of_shards" : 1,
         "number_of_replicas" : 1
      },
    "mappings": {
        "_doc":{
         "properties": {
           "anonymous": {"type": "boolean"},
           "content_text_form": {"type": "text"},
           "details": {"type": "text"},
           "language": {"type": "keyword"},
           "no_of_comments": {"type": "long"},
           "up_votes": {"type": "long"},
           "down_votes": {"type": "long"},
           "no_of_views": {"type": "long"},
           "no_of_impressions": {"type": "long"},
           "short_id": {"type": "keyword"},
           "no_of_reposts": {"type": "long"},
           "createdAt": {"type": "date"},
           "updatedAt": {"type": "date"},
           "re_post_date": {"type": "date"},
           "media_urls": {
                    "properties": {
                      "url": {"type": "keyword"},
                      "type": {"type": "keyword"},
                      "uploadedOn": {"type": "date"},
                      "description": {"type": "text"},
                      "thumbnail": {"type": "text"},
                      "file_type": {"type": "keyword"},
                      "dimensions": {
                        "properties": {
                          "type": {
                            "properties": {
                              "height": {"type": "long"},
                              "width": {"type": "long"},
                              "aspect_ratio":{"type":"long"}
                            }


                          },
                          "required": {"type": "boolean"}
                        }}
                      }
                      },
         "tags": {"type": "keyword"},
          "tag_positions": {
                      "properties": {
                        "tag": {"type": "keyword"},
                        "tag_start": {"type": "long"},
                        "tag_end": {"type": "long"}}},
      "source": {
      "properties": {
        "title" : {"type": "text"},
        "description": {"type": "text"},
        "media_type": {"type": "text"},
        "url": {"type": "text"}
      }
    },
       "moderation": {
      "properties": {
        "done": {"type":"boolean"}
      }
    }
   }
  }
 }
}
 类似资料:
  • 我是Spring MVC和HiberNate的新手。几天来,我一直试图制作一个简单的Spring项目,但在那里遇到了一些错误。错误说org.springframework.beans.factory.不满意的依赖异常:创建名称为“客户DAOImp”的bean时出错 这是我的错误 HTTP状态500-内部服务器错误 类型异常报告 Message内部服务器错误 描述服务器遇到内部错误,无法完成此请求。

  • 我在WEB-INF内的lib文件夹和Tomcat lib中添加了许多jar,试图解决这个问题,但没有结果(commons-beanutils-1.8.1、commons-collections-3.2.1、commons-lang-2.5、commons-logging-1.1.1、ezmorph-1.0.6、java-json、javax.json-1.0、json-lib-2.4-jdk15、

  • 我有一个给定格式的JSON数据: 我想把它转换成地图 我在Kotlin方面没有太多经验,我主要用Python处理过此类案例,我成功地编写了以下内容: 我无法使用将数据添加到地图键值,任何想法或线索都会有所帮助。

  • JKS密钥存储使用专有格式。建议使用“keytool-importkeystore-srckeystore-destkeystore-deststoreType PKCS12”迁移到PKCS12这是一种行业标准格式 在生成密钥时,我在android studio 3.4(32位版本)中得到了这种类型的错误,但当我在另一台使用android studio 3.4(64位版本)的笔记本电脑中生成相同的

  • JKS密钥存储库使用专有格式。建议使用“keytool-importkeystore-srckeystore-destkeystore-deststoretype PKCS12”迁移到PKCS12,它是一种行业标准格式 我在使用android Studio3.4(32位版本)生成密钥时遇到了这种类型的错误,但当我在另一台使用android Studio3.4(64位版本)的笔记本电脑中生成相同的源

  • 我使用的是弹性搜索版本7.1.0和NEST 6.7.0以及ElasticSearch.NET 6.7.0。当我试图创建索引时,我出现了一个错误。 这是我的代码,我在NEST和ElasticSearch.NET 6.4.0版上使用了相同的代码,并且运行良好 null 代码400来自:PUT/local_brainbank_index。servererror:type:mapper_parsing_e