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













网友评论