簡體   English   中英

elasticsearch 映射預期的 map 用於字段 [name] 上的屬性 [fields],但得到了 class Z93F725A07423FE21C846Zlang4。

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

這是我的數據,它基於模式,我需要生成要在 ES 上索引的映射。 我在 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"
}

到目前為止,這是我的映射:

{
                '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'
                }
         }

我的數據中沒有字段“字段”,所以我不確定這意味着什么,“名稱”是一個簡單的字符串

我已經嘗試過了,還包括 "mappings":{"properties":{...}} 但這也失敗了。 任何指針?

嘗試對字段fields使用文本或關鍵字而不是string

string 在 Elasticsearch 中不是有效的數據類型。 您可以使用關鍵字或文字

  • 文本數據類型

    用於索引全文值的字段,例如 email 的正文或產品的描述。 對這些字段進行分析,也就是說,它們在被索引之前通過分析器將字符串轉換為單個術語的列表。 分析過程允許 Elasticsearch 在每個全文字段中搜索單個單詞。 文本字段不用於排序,也很少用於聚合(盡管重要的文本聚合是一個明顯的例外)。

  • 關鍵字數據類型

    用於索引結構化內容的字段,例如 ID、email 地址、主機名、狀態代碼、zip 代碼或標簽。

資料來源: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html

您的映射中有兩個問題

  1. 使用了字符串,它不再是有效的數據類型,請改用文本

  2. 'properties':{'name': 'text'} 應該是 "name":{"type":"text"}

您正在使用歸一化器,我不知道您的要求,因此請檢查您是否需要歸一化器或分析器

更正的映射

"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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM