1、基础操作
检测集群是否健康
get localhost:9200/_cat/health?v 其中 ?v 是为了友好展示
获取集群的节点列表
get localhost:9200/_cat/nodes?v
列出所有索引
get localhost:9200/_cat/indices?v
删除索引
put DELETE 'localhost:9200/house
创建索引
PUT http://127.0.0.1:9200/house
{
"settings":{
"number_of_shards": 3,
"number_of_replicas": 2
},
"mappings":{
"house":{
"dynamic":false,
"properties":{
"houseId":{"type":"long"},
"title":{"type":"text", "index":"true"},
"price":{"type":"integer"},
"createTime":{"type":"date","format":"strict_date_optional_time||epoch_millis"},
"last_modified_time": {"type": "date", "format": "yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" },
"cityEnName":{"type":"keyword"},
"tags":{"type":"keyword"},
"description":{"type":"text", "analyzer":"standard"}
}
}
}
}
注意 ElasticSearch7.X之后的版本默认不在支持指定索引类型,默认索引类型是_doc(隐含:include_type_name=false),所以在mappings节点后面,直接跟properties就可以了。
查看索引
GET http://127.0.0.1:9200/house?pretty
打开和关闭索引
POST http://127.0.0.1:9200/house/_open POST http://127.0.0.1:9200/house/_close