gpt4 book ai didi

python - elasticsearch映射字段[name]上的属性[fields]的预期映射,但是得到了一个类java.lang.String

转载 作者:行者123 更新时间:2023-12-03 02:24:40 24 4
gpt4 key购买 nike

这是我的数据,它基于模式,我需要生成映射以在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”是一个简单的字符串

我已经尝试过了,还包括了“mappings”:{“properties”:{...}},但这也失败了。任何指针?

最佳答案

您的映射中有两个问题

使用了

  • 字符串,它不再是有效的数据类型,请使用文本代替
  • '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"
    }

    关于python - elasticsearch映射字段[name]上的属性[fields]的预期映射,但是得到了一个类java.lang.String,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61378180/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com