欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mapping

程序员文章站 2022-03-08 16:13:22
...

Mapping

store

应用场景:

  1. 一个很长的字符串在source内,查询的时候不想通过_source filter从一个很大的_source中获取
  2. 当Mapping使用copy_to把内容copy到目标字段的时候,想显示目标字段(这时目标字段在_source内不存在)
    "store": true 表示该字段存储在fields内. "store": false 表示不存储。 比如:
PUT my_index
{
  "mappings": {
    "_doc": {
      "properties": {
        "title": {
          "type": "text",
          "store": true 
        },
        "date": {
          "type": "date",
          "store": true 
        },
        "content": {
          "type": "text"
        }
      }
    }
  }
}
PUT my_index/_doc/1
{
  "title":   "Some short title",
  "date":    "2015-01-01",
  "content": "A very long content field..."
}

则在fields内只存储date和title字段,默认store=false:

{
  "_index": "my_index",
  "_type": "_doc",
  "_id": "1",
  "_version": 2,
  "_score": null,
  "_source": {
    "title": "Some short title",
    "date": "2018-10-01",
    "content": "A very long content field..."
  },
  "fields": {
    "date": [
      "2018-10-01T00:00:00.000Z",
    ],
    "title": [
      "Some short title"
    ]
  },
  "sort": [
    1538352000000
  ]
}