Elasticsearch索引基本操作
小于 1 分钟ElasticsearchElasticsearch
索引操作
创建索引
## 创建索引 PUT localhost:9200/nba { "acknowledged": true, "shards_acknowledged": true, "index": "nba" }
获取索引
GET localhost:9200/nba { "nba": { "aliases": {}, "mappings": {}, "settings": { "index": { "creation_date": "1589206816630", "number_of_shards": "1", "number_of_replicas": "1", "uuid": "2u-wlpkKSoaIhp8h9Biqmg", "version": { "created": "7020199" }, "provided_name": "nba" } } } }
删除索引
DELETE localhost:9200/nba { "acknowledged": true }
批量获取
PUT localhost:9200/cba PUT localhost:9200/nba ## 批量获取,用逗号隔开 GET localhost:9200/cba,nba { "cba": { "aliases": {}, "mappings": {}, "settings": { "index": { "creation_date": "1589208603245", "number_of_shards": "1", "number_of_replicas": "1", "uuid": "cuW6GYutR-Sat5vPtMiWCA", "version": { "created": "7020199" }, "provided_name": "cba" } } }, "nba": { "aliases": {}, "mappings": {}, "settings": { "index": { "creation_date": "1589208584555", "number_of_shards": "1", "number_of_replicas": "1", "uuid": "dkBxRSTNTzCasgi_f67F3g", "version": { "created": "7020199" }, "provided_name": "nba" } } }
获取所有索引
GET localhost:9200/_all { "cba": { "aliases": {}, "mappings": {}, "settings": { "index": { "creation_date": "1589208603245", "number_of_shards": "1", "number_of_replicas": "1", "uuid": "cuW6GYutR-Sat5vPtMiWCA", "version": { "created": "7020199" }, "provided_name": "cba" } } }, "nba": { "aliases": {}, "mappings": {}, "settings": { "index": { "creation_date": "1589208584555", "number_of_shards": "1", "number_of_replicas": "1", "uuid": "dkBxRSTNTzCasgi_f67F3g", "version": { "created": "7020199" }, "provided_name": "nba" } } }
关闭索引
POST localhost:9200/nba/_close
打开索引
POST localhost:9200/nba/_open
文档操作
新增文档
##指定ID PUT /nba/_doc/1 { "name":"哈登", "team_name":"⽕箭", "position":"得分后卫", "play_year":"10", "jerse_no":"13" } ## 不指定ID POST /nba/_doc/ { "name":"哈登11", "team_name":"⽕箭", "position":"得分后卫", "play_year":"10", "jerse_no":"13" }
查看指定ID文档
GET /nba/_doc/1
修改指定文档
POST /nba/_update/1 { "doc": { "name":"xwxwxw" } }
删除指定文档
DELETE /nba/_doc/1