ES添加新字段

startshineye

背景

为了业务需要,es存储数据需要添加字段:
image.png

es版本是7.13.x

内容

进行字段迁移时候,需要按照要求修改对应的模板:template、索引mapping。

模板修改

查询对应模板:
GET /_template/template_name
修改模板
PUT /_template/template_name
{
  // 这里是从之前检索到的索引的具体信息
}

在对应模块下添加:

,
"sourceWeight" : {
  "store" : true,
  "type" : "integer"
},
"imgPaths" : {
  "store" : true,
  "type" : "keyword"
},
"filePaths" : {
  "store" : true,
  "type" : "keyword"
},
"extra" : {
  "store" : true,
  "type" : "keyword"
},
"extend" : {
  "store" : true,
  "type" : "text"
}

mapping修改

查询索引mapping
 GET /test_tr_01/_mapping
修改索引mapping
PUT /test_tr*/_mapping
{
 //具体mapping信息
}

修改mapping时候,可以直接添加需要修改的字段会当做,新增的字段添加进去

插入数据

POST /news_en_202110/_doc/341634054400045ENG95B126197D974915
{
    "pubTime" :["1634054400000"],
    "title" :["Latest GDP Tracker: Staycations boost August growth but slowdown ahead"],
    "sentimentType" : [
      0
    ],
    "dataId" : [
      "341634054400045ENG95B126197D974915"
    ],
    "countryCode" : [
      "ENG"
    ],
    "comeFrom" : [
      "QD"
    ],
    "extra" : [
      "要点由于 8 月份增长了 0.4% 以及对前几个月的修正。英国国家统计局现在估计产量仅比 2020 年 2 月疫情爆发前的峰值低 0.8%。"
    ],
    "comeFromDb" : [
      "beijing_zk_210930"
    ],
    "categories" : [
      "智库报告"
    ],
    "text" : [
      "Main pointsThanks to growth of 0.4 per cent in August and revisions to earlier months, the ONS now estimates that output is only 0.8 per cent below its pre-Covid February 2020 peak, with several sectors having already surpassed that level.But supply constraints are growing and likely to persist through the autumn, contributing to the slowdown. We forecast growth of 1.5 per cent in the third quarter of 2021, followed by 0.8 per cent in the fourth quarter.This includes an estimated 0.4 per cent month-on-month growth in September, when supply shortages are likely to have caused disruptions to some industries.Figure 1 - UK GDP “The reopening of the economy continued to support growth in August, with the popularity of domestic holidays contributing to 23 per cent month-on-month growth for hotels and campsites in particular. The fact that consumer-facing services remain 5 per cent below their peak suggests ample room for future catch-up in future too. Elsewhere a further fall in construction output may have been down in part to a reported increase in input costs: something likely to affect the economy more broadly if shortages lead to more generalised price rises over the autumn. The coming months could see something of a two-speed recovery, with sectors most affected by shortages in decline while others continue to recover.”Rory MacqueenPrincipal Economist, NIESRNotes for editors:For further information please contact the NIESR Press Office: press [at] niesr.ac.uk orLuca Pieri on l.pieri [at] niesr.ac.uk / 0207 654 1954National Institute of Economic and Social Research2 Dean Trench StreetSmith SquareLondon, SW1P 3HEUnited Kingdom Switchboard Telephone Number: 020 7222 7665Website: http://www.niesr.ac.uk"
    ],
    "mediaName" : [
      "niesr.ac.uk"
    ],
    "sentimentScore" : [
      0.0
    ],
    "hashKey" : [
      "8B68939A467511A186EC3813AD906822"
    ],
    "author" : [
      ""
    ],
    "updateTime" : [
      "1634135293999"
    ],
    "languageCode" : [
      "en"
    ],
    "similarityId" : [
      ""
    ],
    "url" : [
      "https://www.niesr.ac.uk/media/latest-gdp-tracker-staycations-boost-august-growth-slowdown-ahead-14944"
    ],
    "extend" : [
      ""
    ],
    "siteUrls" : [
      "https://www.niesr.ac.uk/media/latest-gdp-tracker-staycations-boost-august-growth-slowdown-ahead-14944"
    ],
    "createTime" : [
      "1634135293999"
    ],
    "sourceType" : [
      "QDZhikuNews"
    ],
    "crawlTime" : [
      "1634135292867"
    ],
    "domain" : [
      "niesr.ac.uk"
    ],
    "filePaths" : [
      "/QDZhikuNews/2021-10-13/202110133122.pdf"
    ],
    "siteNames" : [
      "英国国家经济社会研究所"
    ],
    "mediaType":[
      "100"
    ],
    "mediaLevel":[
      "5"
      ]
}
阅读 730

我在规定的时间内,做到了我计划的事情;我自己也变得自信了,对于外界的人跟困难也更加从容了,我已经很强...

54 声望
13 粉丝
0 条评论
你知道吗?

我在规定的时间内,做到了我计划的事情;我自己也变得自信了,对于外界的人跟困难也更加从容了,我已经很强...

54 声望
13 粉丝
文章目录
宣传栏