#number_of_shards:分片的數量,mo'ren默認爲5 #number_of_replicas:副本副本的副本的數量 #shards一旦設置不能修改 PUT lagou { "settings": { "index":{ "number_of_shards":5, "number_of_replicas":1 } } }
運行後返回:前端
訪問elasticsearch-head:後端
刷新出現lagouelasticsearch
查看索引信息spa
#獲取lagou索引設置信息 GET lagou/_settings
執行效果3d
#獲取全部索引的setting信息 GET _all/_settings
#獲取全部索引的setting信息
GET _settings #獲取部分指定索引的setting信息 GET .kibana,lagou/_settings
執行效果code
#修改副本數爲2 PUT lagou/_settings { "number_of_replicas":2 }
執行後blog
#獲取全部索引的完整信息 GET _all
#獲取lagou的完整信息
GET lagou
執行後索引
#指定索引爲lagou,表爲job,id爲1 PUT lagou/job/1 { "title":"後端研發", "salary_min":20000, "Company":{ "name":"百度", "address":"北京" } }
執行後文檔
head中可查看it
#不指明id,自動生成id插入 POST lagou/job/ { "title":"前端研發", "salary_min":30000, "Company":{ "name":"阿里", "address":"北京" } }
執行後
查詢
#獲取索引爲lagou,表爲job,id爲1的數據 GET lagou/job/1
執行後
#獲取title和name GET lagou/job/1?_source=title,Company.name
執行後
#直接覆蓋id爲1的文檔 PUT lagou/job/1 { "title":"後端研發", "salary_min":10000, "Company":{ "name":"百度", "address":"北京" } }
#指明字段修改,doc爲固定格式,指明要修改的字段 POST lagou/job/1/_update { "doc": { "salary_min":20000 } }
#刪除索引爲lagou,表爲job,id爲1的數據 DELETE lagou/job/1
#刪除索引,不支持刪除表 DELETE lagou