索引管理——创建,查询,删除

创建最简单的索引

PUT twitter

查询索引

GET twitter

删除索引

DELETE twitter

 

创建最简单的索引,然后查看它有哪些内容

 1 {
 2   "twitter": {  #索引名称
 3     "aliases": {}, #别名
 4     "mappings": {}, #映射是空的
 5     "settings": {   #索引设置
 6       "index": {
 7         "creation_date": "1571121395859",
 8         "number_of_shards": "5",  #分片 默认5
 9         "number_of_replicas": "1", #备份 默认1
10         "uuid": "N3gNve1aRxWSsoboXfX9Cg",
11         "version": {
12           "created": "6040399"
13         },
14         "provided_name": "twitter"
15       }
16     }
17   }
18 }

 

创建索引,设置分片和备份个数

 1 PUT twitter
 2 {
 3   "settings": {
 4     "index":{
 5       "number_of_shards":3,
 6       "number_of_replicas":1
 7     }
 8     
 9   }
10 }
{
  "twitter": {
    "aliases": {},
    "mappings": {},
    "settings": {
      "index": {
        "creation_date": "1571121636491",
        "number_of_shards": "3",
        "number_of_replicas": "1",
        "uuid": "TKf1dfAFSNKTSCASP-QC3A",
        "version": {
          "created": "6040399"
        },
        "provided_name": "twitter"
      }
    }
  }
}
 1 PUT twitter
 2 {
 3   "settings": {
 4       "number_of_shards":3,
 5       "number_of_replicas":1
 6     }
 7 }
 8 
 9 GET twitter
10 
11 {
12   "twitter": {
13     "aliases": {},
14     "mappings": {},
15     "settings": {
16       "index": {
17         "creation_date": "1571121764539",
18         "number_of_shards": "3",
19         "number_of_replicas": "1",
20         "uuid": "KKDYMVmFSHyOovqbB_SEVw",
21         "version": {
22           "created": "6040399"
23         },
24         "provided_name": "twitter"
25       }
26     }
27   }
28 }

 

创建索引,设置mapping内容

 1 PUT twitter
 2 {
 3   "settings": {
 4       "number_of_shards":3,
 5       "number_of_replicas":1
 6     },
 7     "mappings": {
 8       "_doc":{
 9         "properties":{
10         "name":{"type":"text"}
11         }
12       }
13     }
14 }
15 
16 GET twitter
17 
18 {
19   "twitter": {
20     "aliases": {},
21     "mappings": {
22       "_doc": {
23         "properties": {
24           "name": {
25             "type": "text"
26           }
27         }
28       }
29     },
30     "settings": {
31       "index": {
32         "creation_date": "1571122082042",
33         "number_of_shards": "3",
34         "number_of_replicas": "1",
35         "uuid": "aE45unHLTMmGBtHQTdNrMw",
36         "version": {
37           "created": "6040399"
38         },
39         "provided_name": "twitter"
40       }
41     }
42   }
43 }

 

posted on 2019-10-15 15:56  浅蓝色星光  阅读(187)  评论(0编辑  收藏  举报