ES模板

模板主要用來自動創(chuàng)建index,比如每天一個index 便于數(shù)據(jù)清理
創(chuàng)建模板語法:

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"
        }
      }
    ]
  }
}
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • Swift1> Swift和OC的區(qū)別1.1> Swift沒有地址/指針的概念1.2> 泛型1.3> 類型嚴謹 對...
    cosWriter閱讀 11,674評論 1 32
  • 概要 64學時 3.5學分 章節(jié)安排 電子商務網(wǎng)站概況 HTML5+CSS3 JavaScript Node 電子...
    阿啊阿吖丁閱讀 9,874評論 0 3
  • 今天我想到了一句話“努力拼搏了,不一定成功;但是不努力拼搏,一定不會成功”。這句話雖然有點繞口,但是道理卻很深刻。...
    正本閱讀 659評論 0 8
  • 春天在最后的荒蕪里蘊育 聞到雪融化打濕枯葉的味道 無比親切 那是歲月的味道 我站在大橋上 等待春天 風刮過骨頭...
    樹梢的流星閱讀 735評論 3 2
  • 關鍵詞:流浪貓,母愛 全文共755個字,閱讀只需要5分鐘 今天下午出門辦事,停完車路過一個空車位...
    Sebrenna閱讀 231評論 0 0

友情鏈接更多精彩內容