上一章讲述了ELK的搭建,本章主要为elasticsearch的基本使用

1、查看elasticsearch信息
GET /

2、创建索引
PUT /test

3、获取全部索引
GET _cat/indices?v

4、向索引中插入数据
PUT /test/info/1
{
"name":"zhangsan",
"age":20
}

5、获取插入索引的信息
GET /test/info/1

6、获取单条索引的全部信息
GET /test/_search?q=*

7、删除索引中的数据
DELETE /test/info/1

8、更改某一类型的数据



9、批量更改数据
POST /test/_update_by_query
{
"script": {
"source" : "ctx._source['age']=26"
},
"query":{
"match_all": {}
}
}
、
查询所有数据,age已经变更为26
GET /test/_search?q=*

10、为索引增加字段
POST /test/_update_by_query
{
"script": {
"source" : "ctx._source['city']='beijing'"
},
"query":{
"match_all": {}
}
}


本文详细介绍Elasticsearch的基本使用方法,包括查看信息、创建及管理索引、数据的增删改查等核心操作,适合初学者快速上手。
726

被折叠的 条评论
为什么被折叠?



