Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python elasticsearch映射需要字段[name]上属性[fields]的映射,但得到了类java.lang.String_Python_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Mapping - Fatal编程技术网 elasticsearch,mapping,Python,elasticsearch,Mapping" /> elasticsearch,mapping,Python,elasticsearch,Mapping" />

Python elasticsearch映射需要字段[name]上属性[fields]的映射,但得到了类java.lang.String

Python elasticsearch映射需要字段[name]上属性[fields]的映射,但得到了类java.lang.String,python,elasticsearch,mapping,Python,elasticsearch,Mapping,这是我的数据,它基于一个模式,我需要生成映射以在ES上建立索引。我在ES方面的背景不多,但我一直以为我得到了它,直到我尝试了它,但失败了,在网上找不到正确的答案 { "@context": { "schema": "http://schema.org/", "outbreak": "https://discovery.biothings.io/view/outbreak/" }, "@type": "outbreak:Publication", "keywords

这是我的数据,它基于一个模式,我需要生成映射以在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'
                }
         }
我的数据中没有字段“fields”,所以我不确定这是什么意思,“name”是一个简单的字符串


我尝试过这个方法,还包括了“映射”:{“属性”:{…}},但也失败了。任何指针???

尝试在字段
字段中使用文本或关键字,而不是
字符串

字符串不是Elasticsearch中的有效数据类型。您可以使用关键字或文本

  • 文本数据类型

    用于索引全文值的字段,如电子邮件正文或产品说明。对这些字段进行分析,也就是说,在索引之前,这些字段通过分析器将字符串转换为单个术语的列表。分析过程允许Elasticsearch在每个全文字段中搜索单个单词。文本字段不用于排序,很少用于聚合(尽管重要的文本聚合是一个显著的例外)

  • 关键字数据类型

    用于索引结构化内容(如ID、电子邮件地址、主机名、状态码、邮政编码或标记)的字段


来源:

您的映射中存在两个问题

  • 已使用字符串,它不再是有效的数据类型,请改用文本

  • 'properties':{'name':'text'}应该是“name”:{“type”:“text”}

  • 您正在使用normalizer,我不知道您的需求,所以请检查是否需要normalizer或analyzer

    校正映射

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

    我将运行这将需要一些时间,并提供更新,现在感谢!工作完成了,是的,这就是问题所在,泰!