【Elasticsearch】第6篇:Elasticsearch的CURD
curl简单介绍
简单的认为是可以在命令行下面访问url的一个工具,使用curl可以简单实现常见的get/post请求。curl命令详解
curl 命令:
-X 指定http的请求方法 有HEAD GET POST PUT DELETE -d 指定要传输的数据 -H 指定http请求头信息 -i 获取响应头
cat系列
用于获取Elasticsearch集群状态接口
curl -XGET 'http://localhost:9200/_cat'
接口展示:
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templatescluster系列
1.集群系统信息,包括CPU JVM等
curl -XGET 'https://localhost:9200/_cluster/stats?pretty=true'
2.集群的详细信息,节点、分片等
curl -XGET 'http://localhost:9200/_cluster/state?pretty=true'
3.集群堆积的任务
curl -XGET 'http://localhost:9200/_cluster/pending_tasks?pretty=true'
集群关闭操作
1.关闭集群节点
curl -XPOST 'http://localhost:9200/_cluster/nodes/127.0.0.1/_shutdown'
2.关闭主节点
curl -XPOST 'http://localhost:9200/_cluster/nodes/_master/_shutdown'
3.关闭整个集群
curl -XPOST 'http://localhost:9200/_cluster/nodes/_all/_shutdown'
Index的建立和删除
查看全部索引
curl -XGET 'http://localhost:9200/_cat/indices?v'
新建Index
1.命令创建:
curl -XPUT 'http://localhost:9200/city'
结果:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "city"
}2.elasticsearch-head创建:

3.删除索引
curl -XDELETE 'http://localhost:9200/account'
数据的简单操作
添加数据
curl -H 'Content-Type: application/json' -XPOST 'http://localhost:9200/city/south/1' -d '{"cityName":"guangzhou"}'结果
{
"_index":"city",
"_type":"south",
"_id":"1",
"_version":1,
"result":"created",
"_shards":{
"total":2,
"successful":2,
"failed":0
},
"_seq_no":0,
"_primary_term":1
}查询数据
curl -i -XGET 'http://localhost:9200/city/south/1'
结果
{
"_index":"city",
"_type":"south",
"_id":"1",
"_version":1,
"found":true,
"_source":{
"cityName":"guangzhou"
}
}删除数据
curl -XDELETE 'http://localhost:9200/city/south/1'
结果
{
"_index":"city",
"_type":"south",
"_id":"1",
"_version":2,
"result":"deleted",
"_shards":{
"total":2,
"successful":2,
"failed":0
},
"_seq_no":1,
"_primary_term":1
}更新数据
curl -i -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/city/south/1' -d '{"cityName":"HUNAN"}'结果
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 153
{
"_index":"city",
"_type":"south",
"_id":"1",
"_version":2,
"result":"updated",
"_shards":{
"total":2,
"successful":2,
"failed":0
},
"_seq_no":3,
"_primary_term":2
} 相关推荐
做对一件事很重要 2020-09-07
newbornzhao 2020-09-14
renjinlong 2020-09-03
明瞳 2020-08-19
李玉志 2020-08-19
mengyue 2020-08-07
molong0 2020-08-06
AFei00 2020-08-03
molong0 2020-08-03
wenwentana 2020-08-03
YYDU 2020-08-03
另外一部分,则需要先做聚类、分类处理,将聚合出的分类结果存入ES集群的聚类索引中。数据处理层的聚合结果存入ES中的指定索引,同时将每个聚合主题相关的数据存入每个document下面的某个field下。
sifeimeng 2020-08-03
心丨悦 2020-08-03
liangwenrong 2020-07-31
sifeimeng 2020-08-01
mengyue 2020-07-30
tigercn 2020-07-29