es-DSL-index管理操作相关
版本为7.3.2,主要记录index,settings,mappings相关的操作,方便快速测试,调试
7版本已经不需要指定_doc属性,以下可忽略_doc
获取某个索引的mapping信息
GET http://localhost:9200/<index_name>/_mapping
给text类型添加keyword属性
PUT http://localhost:9200/<index_name>/_mapping { "properties": { "your_field": { "type": "text", "fields":{ "keyword":{ "type":"keyword", "ignore_above":256 } } } } } 结果: { "acknowledged" : true }
创建一个普通的索引(示例中包含了各种类型,text指定多字段,date指定格式)
PUT http://localhost:9200/<index_name> { "settings": { "number_of_shards": 5, "number_of_replicas": 2 }, "mappings": { "dynamic":"false", "properties": { "field1": { "type": "keyword" }, "field2": { "type": "integer" }, "field3": { "type": "long" }, "field4": { "type": "date" , "format": "yyyy-MM-dd HH:mm:ss||epoch_millis" }, "field5": { "type": "text" }, "field6": { "type":"text", "fields":{ "keyword":{ "type":"keyword", "ignore_above":256 } } } } } }
创建一个动态mapping的index,并指定某些字段,并允许新字段
put http://localhost:9200/<index_name> { "mappings": { "dynamic": "true", "properties": { "field1":{ "type":"keyword"}, "field2":{ "type":"integer"}, "field3":{"type": "long"}, "field4":{"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.SSS'Z'"
}
}
}
删除索引(一般都会设置禁止批量删除.....)
DELETE http://10.192.78.27:39200/<index_name>