Elasticsearch——DevTools

RESTful 接口 URL 的格式是:http://cluster的地址: 9200/
其中,index, type 是必须提供的( index 可以理解为数据库;type 理解为数据表); id 是可选的(相当于数据库表中记 录的主键是唯一的。如果不提供, Elasticsearch 会向动生成。增 、删、改,查分别对应 HTTP 请求的 PUT 、DELETE、POST、GET方法。

Kibana DevTools

创建

es自动生成id创建数据,自动生成的id 长度是20个字符,采用GUID算法,保证分布式系统,不同节点同一个时间点创建_id`生成不可能发生冲突

POST /province/citys/
{
  "name":"上海",
  "code":"021"
}

返回结果

{
  "_index": "province",
  "_type": "citys",
  "_id": "VV6_G2YBajYJa8_UqerL",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 0,
  "_primary_term": 1
}

bulk批量导入

POST _bulk
{ "index" : { "_index" : "test", "_type" : "_doc", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "_doc", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "_doc", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "_doc", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }

导入结果

curl命令行

创建索引

插入数据指定id

插入数据不指定id


修改

修改单个field

只想修改id唯一的field是name的值

替换数据

这个行为是替换数据,和修改数据是两种不同形式的数据更新


查询

查看es状态

查看es的健康状态

查看es的index

删除

删除索引

删除字段

删除数据

返回结果

删除Type

reindex数据迁移

本文同步分享在 博客“羊羽”(other)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

评论

暂无评论