轻松学会Elasticsearch+kibana
2023-12-14 10:36:52
轻松学会Elasticsearch+kibana
1、创建模板
PUT _template/test
{
"template": "test*",
"mappings": {
"properties": {
"id": { "type": "integer" },
"name": { "type": "keyword" }
}
}
}
返回值
{
"acknowledged" : true
}
2、测试获取模板
GET _template/test
返回值
{
"test" : {
"order" : 0,
"index_patterns" : [
"test*"
],
"settings" : { },
"mappings" : {
"properties" : {
"name" : {
"type" : "keyword"
},
"id" : {
"type" : "integer"
}
}
},
"aliases" : { }
}
}
3、删除模板
DELETE _template/test
返回值
{
"acknowledged" : true
}
4、创建索引
PUT test
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2
}
}
返回值
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "test"
}
5、查看索引
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"
}
}
}
}
6、给已有索引增加字段
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"
}
}
}
}
7、给新增字段初始值
示例中更没有加任何筛选条件,默认是全部数据初始化值为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" : [ ]
}
8、删除索引
DELETE test
返回值
{
"acknowledged" : true
}
文章来源:https://blog.csdn.net/qq_35716085/article/details/134976541
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!