ElasticSearch(7.2.2)-索引的介紹和使用

  • 2019 年 10 月 30 日
  • 筆記

版權聲明:本文為部落客原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。

本文鏈接:https://blog.csdn.net/weixin_42528266/article/details/102796160

簡介:手把手進行索引的操作

新增
  • 請求
curl -X PUT "localhost:9200/nba"
  • 響應
{   "acknowledged": true,   "shards_acknowledged": true,   "index": "nba"  }
獲取/查詢
  • 請求
curl -X GET "localhost:9200/nba"
  • 響應
{  	"nba": {  		"aliases": {},  		"mappings": {},  		"settings": {  			"index": {  				"creation_date": "1563078001824",  				"number_of_shards": "1",  				"number_of_replicas": "1",  				"uuid": "P-kmcRGlRECcBxAI_8mgaw",  				"version": {  					"created": "7020099"  				},  				"provided_name": "nba"  			}  		}  	}  }
刪除
  • 請求
curl -X DELETE "localhost:9200/nba"
  • 響應
{   "acknowledged": true  }
批量獲取
  • 請求
curl -x GET "localhost:9200/nba,cba"
  • 響應
{  	"cba": {  		"aliases": {},  		"mappings": {},  		"settings": {  			"index": {  				"creation_date": "1563078437245",  				"number_of_shards": "1",  				"number_of_replicas": "1",  				"uuid": "3rGtXSv_QTK-GU_xHKRvmw",  				"version": {  					"created": "7020099"  				},  				"provided_name": "cba"  			}  		}  	},  	"nba": {  		"aliases": {},  		"mappings": {},  		"settings": {  			"index": {  				"creation_date": "1563078431931",  				"number_of_shards": "1",  				"number_of_replicas": "1",  				"uuid": "bP6CZH5jSTGlhrTDzlq0bw",  				"version": {  					"created": "7020099"  				},  				"provided_name": "nba"  			}  		}  	}  }
獲取所有
  • 請求(一)
curl -X GET "localhost:9200/_all"
  • 響應(一)
{  	"cba": {  		"aliases": {},  		"mappings": {},  		"settings": {  			"index": {  				"creation_date": "1563078437245",  				"number_of_shards": "1",  				"number_of_replicas": "1",  				"uuid": "3rGtXSv_QTK-GU_xHKRvmw",  				"version": {  					"created": "7020099"  				},  				"provided_name": "cba"  			}  		}  	},  	"nba": {  		"aliases": {},  		"mappings": {},  		"settings": {  			"index": {  				"creation_date": "1563078431931",  				"number_of_shards": "1",  				"number_of_replicas": "1",  				"uuid": "bP6CZH5jSTGlhrTDzlq0bw",  				"version": {  					"created": "7020099"  				},  				"provided_name": "nba"  			}  		}  	}  }
  • 請求(⼆)
curl -X GET "localhost:9200/_cat/indices?v"
  • 響應(二)
health status index uuid pri rep docs.count  docs.deleted store.size pri.store.size  yellow open   nba   bP6CZH5jSTGlhrTDzlq0bw   1    1    0         0           230b         230b  yellow open   cba   3rGtXSv_QTK-GU_xHKRvmw   1    1    0        0            230b         230b
存在
  • 請求
curl -I "localhost:9200/nba"
  • 響應
200  ok
關閉
  • 請求
curl -X POST "localhost:9200/nba/_close"
  • 響應
{   "acknowledged": true,   "shards_acknowledged": true  }
打開
  • 請求
curl -X POST "localhost:9200/nba/_open"
  • 響應
{   "acknowledged": true,   "shards_acknowledged": true  }

Tags: