简体   繁体   English

elasticsearch 映射预期的 map 用于字段 [name] 上的属性 [fields],但得到了 class Z93F725A07423FE21C846Zlang4。

[英]elasticsearch mapping Expected map for property [fields] on field [name] but got a class java.lang.String

Here is my data, It's based on a schema and I need to generate mapping to be indexed on ES.这是我的数据,它基于模式,我需要生成要在 ES 上索引的映射。 My background with ES is not much but I thought I got it until I tried it and failed and can't find the right answer online..我在 ES 方面的背景并不多,但我以为我得到了它,直到我尝试它并失败并且无法在网上找到正确的答案..

{
  "@context": {
    "schema": "http://schema.org/",
    "outbreak": "https://discovery.biothings.io/view/outbreak/"
  },
  "@type": "outbreak:Publication",
  "keywords": [
    "COVID-19",
    "City lockdown",
    "Epidemic",
    "Governmental action",
    "Individual reaction",
    "Mathematical modelling"
  ],
  "author": [
    {
      "@type": "outbreak:Person",
      "affiliation": [
        {
          "@type": "outbreak:Organization",
          "name": "Department of Applied Mathematics, Hong Kong Polytechnic University, Hong Kong, China. Electronic address: daihai.he@polyu.edu.hk."
        }
      ],
      "familyName": "He",
      "givenName": "Daihai",
      "name": "Daihai He"
    }
  ],
  "publicationType": [
    "Journal Article"
  ],
  "_id": "pmid32145465",
  "curatedBy": {
    "@type": "schema:WebSite",
    "name": "litcovid",
    "url": "https://www.ncbi.nlm.nih.gov/research/coronavirus/publication/32145465"
  },
  "name": "A conceptual model for the coronavirus disease 2019 (COVID-19) outbreak in Wuhan, China with individual reaction and governmental action.",
  "identifier": "32145465",
  "pmid": "32145465",
  "abstract": "The ongoing coronavirus disease 2019 (COVID-19) outbreak, emerged in Wuhan, China in the end of 2019, has claimed more than 2600 lives as of 24 February 2020 and posed a huge threat to global public health. The Chinese government has implemented control measures including setting up special hospitals and travel restriction to mitigate the spread. We propose conceptual models for the COVID-19 outbreak in Wuhan with the consideration of individual behavioural reaction and governmental actions, e.g., holiday extension, travel restriction, hospitalisation and quarantine. We employe the estimates of these two key components from the 1918 influenza pandemic in London, United Kingdom, incorporated zoonotic introductions and the emigration, and then compute future trends and the reporting ratio. The model is concise in structure, and it successfully captures the course of the COVID-19 outbreak, and thus sheds light on understanding the trends of the outbreak.",
  "license": "Copyright © 2020 The Authors. Published by Elsevier Ltd.. All rights reserved.",
  "journalName": "International journal of infectious diseases : IJID : official publication of the International Society for Infectious Diseases",
  "journalAbbreviation": "Int. J. Infect. Dis.",
  "issueNumber": "1878-3511",
  "doi": "S1201-9712(20)30117-X",
  "url": "https://www.doi.org/S1201-9712(20)30117-X",
  "datePublished": "2020-03-04",
  "dateModified": "2020-02-26"
}

and here is my mapping so far:到目前为止,这是我的映射:

{
                'fields':{
                    'type': 'string'
                },
                'abstract': {
                    'type': 'text'
                },
                'pmid': {
                    'type': 'integer'
                },
                'author': {
                    'type': 'nested',
                    'properties': {
                        'name':{
                            'type': 'text'
                        },
                        'givenName':{
                            'type': 'text'
                        },
                        'familyName':{
                            'type': 'text'
                        },
                        'affiliation':{
                            'type': 'nested',
                            'properties': {
                                'name':{
                                    'type': 'text'
                                }
                            }
                        }
                    }
                },
                'isBasedOn': {
                    'type': 'text'
                },
                'funding': {
                    'type': 'nested',
                    'properties': {
                        'funder':{
                            'type': 'nested',
                            'properties':{
                                'name': 'text'
                            }
                        },
                        'identifier':{
                            'type': 'text'
                        }
                    }
                },
                'license': {
                    'type': 'text'
                },
                'keywords': {
                    'normalizer': 'keyword_lowercase_normalizer',
                    'type': 'keyword',
                    'copy_to': ['all']
                },
                'publicationType': {
                    'normalizer': 'keyword_lowercase_normalizer',
                    'type': 'keyword',
                    'copy_to': ['all']
                },
                'name': {
                    'type': 'text'
                },
                'journalName': {
                    'type': 'text'
                },
                'identifier': {
                    'type': 'text'
                },
                'doi': {
                    'type': 'text'
                },
                'datePublished': {
                    'type': 'date'
                },
                'dateModified': {
                    'type': 'date'
                },
                'issueNumber': {
                    'type': 'text'
                }
         }

I don't have a field "fields" in my data so I'm not sure what this means and "name" is a simple string我的数据中没有字段“字段”,所以我不确定这意味着什么,“名称”是一个简单的字符串

I've tried this and also including "mappings":{"properties":{...}} but that also fails.我已经尝试过了,还包括 "mappings":{"properties":{...}} 但这也失败了。 Any pointers??任何指针?

Try to use text or keyword instead of string for field fields尝试对字段fields使用文本或关键字而不是string

string is not a valid data type in Elasticsearch. string 在 Elasticsearch 中不是有效的数据类型。 You could either use keyword or text您可以使用关键字或文字

  • Text data Type文本数据类型

    A field to index full-text values, such as the body of an email or the description of a product.用于索引全文值的字段,例如 email 的正文或产品的描述。 These fields are analyzed, that is they are passed through an analyzer to convert the string into a list of individual terms before being indexed.对这些字段进行分析,也就是说,它们在被索引之前通过分析器将字符串转换为单个术语的列表。 The analysis process allows Elasticsearch to search for individual words within each full text field.分析过程允许 Elasticsearch 在每个全文字段中搜索单个单词。 Text fields are not used for sorting and seldom used for aggregations (although the significant text aggregation is a notable exception).文本字段不用于排序,也很少用于聚合(尽管重要的文本聚合是一个明显的例外)。

  • Keyword data type关键字数据类型

    A field to index structured content such as IDs, email addresses, hostnames, status codes, zip codes or tags.用于索引结构化内容的字段,例如 ID、email 地址、主机名、状态代码、zip 代码或标签。

Source: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html资料来源: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html

There were two issues in your mapping您的映射中有两个问题

  1. string was used, it is no longer valid data type, use text instead使用了字符串,它不再是有效的数据类型,请改用文本

  2. 'properties':{'name': 'text'} should be "name":{"type":"text"} 'properties':{'name': 'text'} 应该是 "name":{"type":"text"}

You are using normalizer, I don't know your requirement so have a check if you need normalizer or analyzer您正在使用归一化器,我不知道您的要求,因此请检查您是否需要归一化器或分析器

Corrected mapping更正的映射

"fields": {
        "type": "text"
      },
      "abstract": {
        "type": "text"
      },
      "pmid": {
        "type": "integer"
      },
      "author": {
        "type": "nested",
        "properties": {
          "name": {
            "type": "text"
          },
          "givenName": {
            "type": "text"
          },
          "familyName": {
            "type": "text"
          },
          "affiliation": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "text"
              }
            }
          }
        }
      },
      "isBasedOn": {
        "type": "text"
      },
      "funding": {
        "type": "nested",
        "properties": {
          "funder": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "text"
              }
            }
          },
          "identifier": {
            "type": "text"
          }
        }
      },
      "license": {
        "type": "text"
      },
      "keywords": {
        "normalizer": "keyword_lowercase_normalizer",
        "type": "keyword",
        "copy_to": [
          "all"
        ]
      },
      "publicationType": {
        "normalizer": "keyword_lowercase_normalizer",
        "type": "keyword",
        "copy_to": [
          "all"
        ]
      },
      "name": {
        "type": "text"
      },
      "journalName": {
        "type": "text"
      },
      "identifier": {
        "type": "text"
      },
      "doi": {
        "type": "text"
      },
      "datePublished": {
        "type": "date"
      },
      "dateModified": {
        "type": "date"
      },
      "issueNumber": {
        "type": "text"
      }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spark DF 枢轴错误:方法枢轴([类 java.lang.String,类 java.lang.String])不存在 - Spark DF pivot error: Method pivot([class java.lang.String, class java.lang.String]) does not exist pyspark Py4J 错误使用 canopy :PythonAccumulatorV2([class java.lang.String, class java.lang.Integer, class java.lang.String]) 不存在 - pyspark Py4J error using canopy :PythonAccumulatorV2([class java.lang.String, class java.lang.Integer, class java.lang.String]) does not exist JPype1=0.7.0: TypeError: Unable to convert str ro java type class java.lang.String - JPype1=0.7.0: TypeError: Unable to convert str ro java type class java.lang.String 预期的字符串获取了属性 - expected string got property instead 将 java.lang.string 转换为 PYthon 字符串/字典 - Converting java.lang.string to PYthon string/dictionary Django 字段'id'需要一个数字但得到'<string> '</string> - Django Field 'id' expected a number but got '<string>' jinja:TemplateSyntaxError:期望令牌&#39;name&#39;,得到&#39;string&#39; - jinja: TemplateSyntaxError: expected token 'name', got 'string' 出现Elasticsearch映射错误时如何查看显式字段名称 - How to see explicit field name when having an elasticsearch mapping error Jinja通过“ SyntaxError:预期的属性名称,得到了&#39;%&#39;”错误 - Jinja throughs “SyntaxError: expected property name, got '%' ” error 小鸭,int() 参数必须是一个字符串,一个类似字节的 object 或一个数字,而不是 'java.lang.String', - Duckling, int() argument must be a string, a bytes-like object or a number, not 'java.lang.String',
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM