这一篇的api是另一篇文章中api的补充和详解:
https://blog.csdn.net/weixin_38019299/article/details/86700190
1 ,检查所有的节点是否已经加入集群
http://localhost:9200/_cat/health
http://localhost:9200/_cat/nodes
2,集群的恢复情况
http://localhost:9200/_cat/recovery
3,时间参数的URL ,URL编码问题将/转换为%2F
//shop_202004
http://localhost:9200/<shop_{
now%2FM{
YYYYMM}}>/_search
//shop_2020.04.23
http://localhost:9200/<shop_{
now%2Fd-2d}>/_search
4,查看索引状态
http://localhost:9200/_cat/indices?v
5,插入数据PUT请求
PUT请求
http://localhost:9200/shop_log_202003/shop_log_202003/1/
{
"ip":"127.0.0.1",
"action":"query"
}
6,更新数据doc
POST请求
http://localhost:9200/shop_log_202003/shop_log_202003/1/_update
{
"doc": {
"ip":"127.0.0.1",
"action":"query"
}
}
7,查询文档
GET请求
http://localhost:9200/shop_log_202003/shop_log_202003/1
结果:
{
"_index": "shop_log_202003",
"_type": "shop_log_202003",
"_id": "1",
"_version": 2,
"found": true,
"_source": {
"ip": "127.0.0.1",
"action": "query"
}
}
8,删除文档
http://localhost:9200/shop_log_202003/shop_log_202003/2
{
"_index": "shop_log_202003",
"_type": "shop_log_202003",
"_id": "2",
"_version": 2,
"result": "deleted",
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"_seq_no": 7,
"_primary_term": 1
}
9,删除索引库
DELETE请求
http://localhost:9200/shop_log_202003/
10,创建索引设置分片number_of_shards主分片,number_of_replicas副本
PUT请求
http://localhost:9200/shop_log_202004/
{
"settings":{
"number_of_shards":1,
"number_of_replicas":0
}
}
或者
{
"settings":{
"index":{
"number_of_shards":1,
"number_of_replicas":0
}
}
}
11,修改副本数
PUT请求
http://localhost:9200/shop_log_202004/_settings/
{
"number_of_replicas": 1
}