Mapping

作者: 风云傲天 | 来源:发表于2018-11-15 00:08 被阅读0次

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

    相关文章

      网友评论

          本文标题:Mapping

          本文链接:https://www.haomeiwen.com/subject/ptqefqtx.html