版本为7.3.2,主要记录index,settings,mappings相关的操作,方便快速测试,调试
7版本已经不需要指定_doc属性,以下可忽略_doc
获取某个索引的mapping信息
get http://10.192.78.27:39200/<index_name>/_mapping
创建一个动态mapping的index,并指定某些字段,并允许新字段
put http://10.192.78.27:39200/<index_name>
{
"mappings": {
"dynamic": "true",
"properties": {
"id":{ "type":"keyword"},
"rule_name": { "type": "keyword" },
"metric_threshold":{ "type":"integer"},
"audit_status":{"type": "integer"},
"audit_comment_num":{"type":"integer"},
"metric_count":{"type":"integer"},
"window_start":{"type":"date"},
"window_end":{"type":"date"}
}
}
}
在当前索引的mapping下新增加一个字段
加一个指定了format的date类型字段window_start
PUT http://10.192.78.27:39200/<index_name>/_mapping/
{
"properties": {
"window_start": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZ"
}
}
}
date类型字段问题
format属性官网地址:https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html#date-params
自定义时间格式属性:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html
PUT index_name { "mappings": { "_doc": { "properties": { "create_time": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||epoch_millis" } } } } }
删除索引(一般都会设置禁止批量删除.....)
DELETE http://10.192.78.27:39200/<index_name>