PUT _template/test
{
"template": "test*",
"mappings": {
"properties": {
"id": { "type": "integer" },
"name": { "type": "keyword" }
}
}
}
返回值
{
"acknowledged" : true
}
GET _template/test
返回值
{
"test" : {
"order" : 0,
"index_patterns" : [
"test*"
],
"settings" : { },
"mappings" : {
"properties" : {
"name" : {
"type" : "keyword"
},
"id" : {
"type" : "integer"
}
}
},
"aliases" : { }
}
}
DELETE _template/test
返回值
{
"acknowledged" : true
}
PUT test
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2
}
}
返回值
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "test"
}
GET test
返回值
{
"test" : {
"aliases" : { },
"mappings" : {
"properties" : {
"id" : {
"type" : "integer"
},
"name" : {
"type" : "keyword"
}
}
},
"settings" : {
"index" : {
"creation_date" : "1702458256558",
"number_of_shards" : "3",
"number_of_replicas" : "2",
"uuid" : "EnJWQWRRSViuNxiTYoFE3w",
"version" : {
"created" : "7040099"
},
"provided_name" : "test"
}
}
}
}
PUT test/_mapping
{
"properties": {
"is_collect": {
"type": "integer"
}
}
}
返回值
{
"acknowledged" : true
}
再次查看确认即可看到新增的字段
{
"test" : {
"aliases" : { },
"mappings" : {
"properties" : {
"id" : {
"type" : "integer"
},
"is_collect" : {
"type" : "integer"
},
"name" : {
"type" : "keyword"
}
}
},
"settings" : {
"index" : {
"creation_date" : "1702458256558",
"number_of_shards" : "3",
"number_of_replicas" : "2",
"uuid" : "EnJWQWRRSViuNxiTYoFE3w",
"version" : {
"created" : "7040099"
},
"provided_name" : "test"
}
}
}
}
示例中更没有加任何筛选条件,默认是全部数据初始化值为2
修改数据请慎重!!!!!!
POST test/_update_by_query
{
"script": {
"source": "ctx._source.is_collect = 2"
},
"query": {
"match_all": {}
}
}
返回值
{
"took" : 4,
"timed_out" : false,
"total" : 0,
"updated" : 0,
"deleted" : 0,
"batches" : 0,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until_millis" : 0,
"failures" : [ ]
}
DELETE test
返回值
{
"acknowledged" : true
}