有別于關系型數據庫的字段存儲寇荧。es的document用json數據格式來表達,面向文檔存儲户侥。
集群的健康狀況:GET /_cat/health?v
查看所有索引:GET /_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .kibana YTDY7pmFRFu4HaXWz5D9qw 1 0 1 0 4kb 4kb
green:每個索引的primary shard和replica shard都是active狀態(tài)的
yellow:每個索引的primary shard都是active狀態(tài)的蕊唐,但是部分replica shard不是active狀態(tài)寻仗,處于不可用的狀態(tài)
red:不是所有索引的primary shard都是active狀態(tài)的,部分索引有數據丟失了
為了容錯耙替,primary shard和replica shard是不允許在同一臺機器上曹体。在7.0.0中,默認的分片數量將從[5]更改為[1]铜幽,之前版本是默認5個primary shard + 5個replica shard
創(chuàng)建索引:PUT /test_index?pretty
獲取索引信息:GET /test_index
刪除索引:DELETE /test_index?pretty
es會自動建立index和type,不需要提前創(chuàng)建除抛,而且es默認會對document每個field都建立倒排索引母截,讓其可以被搜索。
## 插入文檔 or 替換更新文檔
PUT /hero/hero/1
{
"name" : "wu song",
"alias" : "xing zhe",
"power" : 80,
"tags": [ "kill tiger", "panjinlian" ]
}
## 獲取文檔
GET /hero/hero/1
{
"_index": "hero",
"_type": "hero",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "wu song",
"alias": "xing zhe",
"power": 80,
"tags": [
"kill tiger",
"panjinlian"
]
}
}
## 更新文檔护蝶,相比較PUT方式持灰,不需要帶上所有field
POST /hero/hero/1/_update
{
"doc": {
"tags": ["kill tiger","wuerlang"]
}
}
## 刪除文檔
DELETE /hero/hero/1