ES模板

模板主要用来自动创建index,比如每天一个index 便于数据清理
创建模板语法:

PUT /_template/article_rowkey_data 
{
    "order": 0,
    "template": "article_rowkey_data-*",
    "settings": {
      "index": {
        "number_of_shards": "2",
        "number_of_replicas": "1"
      }
    },
    "mappings": {
      "rd": {
        "_all": {
          "analyzer": "ik_smart",
          "search_analyzer": "ik_smart",
          "term_vector": "with_positions_offsets",
          "store": "false"
        },
        "dynamic_templates": [
          {
            "strings": {
              "match_mapping_type": "string",
              "mapping": {
                "ignore_above": 2048,
                "type": "keyword"
              }
            }
          }
        ],
        "properties": {
          "f_date": {
            "type": "date",
            "format": "yyyyMMdd"
          }
        }
      }
    },
    "aliases": {
      "article_rowkey_data": {}
    }
}
POST /article_rowkey_data-20191113/rd/
{
    "f_date" :  "20191113",
    "last_name" :   "Smith",
    "age" :         32,
    "about" :       "I like to collect rock albums"
}

POST /article_rowkey_data-20191114/rd/
{
    "f_date" :  "20191114",
    "last_name" :   "Smith2",
    "age" :         32,
    "about" :       "I like to collect rock albums"
}
GET /article_rowkey_data-*/rd/_search
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 4,
    "successful": 4,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 1,
    "hits": [
      {
        "_index": "article_rowkey_data-20191113",
        "_type": "rd",
        "_id": "krwRbm4BhjlOtBpWgl6S",
        "_score": 1,
        "_source": {
          "f_date": "20191113",
          "last_name": "Smith",
          "age": 32,
          "about": "I like to collect rock albums"
        }
      },
      {
        "_index": "article_rowkey_data-20191114",
        "_type": "rd",
        "_id": "1IQRbm4BIsqYYEXnR8TE",
        "_score": 1,
        "_source": {
          "f_date": "20191114",
          "last_name": "Smith",
          "age": 32,
          "about": "I like to collect rock albums"
        }
      }
    ]
  }
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,701评论 1 32
  • 概要 64学时 3.5学分 章节安排 电子商务网站概况 HTML5+CSS3 JavaScript Node 电子...
    阿啊阿吖丁阅读 9,884评论 0 3
  • 今天我想到了一句话“努力拼搏了,不一定成功;但是不努力拼搏,一定不会成功”。这句话虽然有点绕口,但是道理却很深刻。...
    正本阅读 660评论 0 8
  • 春天在最后的荒芜里蕴育 闻到雪融化打湿枯叶的味道 无比亲切 那是岁月的味道 我站在大桥上 等待春天 风刮过骨头...
    树梢的流星阅读 740评论 3 2
  • 关键词:流浪猫,母爱 全文共755个字,阅读只需要5分钟 今天下午出门办事,停完车路过一个空车位...
    Sebrenna阅读 233评论 0 0

友情链接更多精彩内容