ES模板

作者: sealwang24 | 来源:发表于2019-11-15 19:33 被阅读0次

模板主要用来自动创建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"
        }
      }
    ]
  }
}

相关文章

  • ES6模版字符串

    初探ES6:字符串模板 && 标签模板 关键词:``,${} 字符串模板: 在ES6之前我们要在html或者con...

  • ES模板

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

  • ES支持中文&&全拼&&拼音首字母搜索

    环境 Ubuntu18.04 ES 6.6.1 搜索模板 新建模板,便于后续创建索引,直接使用模板,省事方便 新建...

  • es6${}、for循环for-of

    Template Literals(模板对象) in ES6 如在es5中拼凑字符串需要+''以及变量名 在es6...

  • NDK OpenGL ES 3.0 开发(十一):模板测试

    该原创文章首发于微信公众号:字节流动 OpenGL ES 模板测试 模板测试与深度测试类似,主要作用是利用模板缓冲...

  • ES的基础使用

    索引模板 如果更改了模板不能对已存在索引生效 创建索引 下面创建一个名字为 laravel_es 的模板,mapp...

  • ES6最棒的新特性

    ES6中的默认参数 ES5的写法 在ES6中,我们可以把默认值直接放进函数签名 ES6中的模板表达式 ES5的写法...

  • ES集群数据迁移

    记录一次ES数据库的迁移 起因是由于老库中的模板映射不是我们想要的模板,需要将数据迁移到新的ES集群中,新集群已经...

  • es6十大特性

    Default Parameters(默认参数) in ES6 Template Literals (模板文本)i...

  • 一文看懂ES6十大特性

    Default Parameters(默认参数) in ES6 Template Literals (模板文本)i...

网友评论

      本文标题:ES模板

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