ES常用命令

kibana模式下增删改查
直接使用sql命令查询
POST /_sql?format=txt
{
“query”:“select * from table where condtion”
}
查询ES中所有index
GET /_cat/indices?v
GET _all
删除对应index
DELETE /<index名>
插入数据
PUT /index/type/id
{
“<列名>”:“<值>”,
“<列名>”:“<值>”
}
删除数据
DELETE /index/type/id
查看所有数据
GET /index/type/_search
match匹配(全文检索)
GET /index/type/_search
{
“query”:{
“match”:{
“title”:“ES tutorial”
}
}
}
sort排序
GET /index/type/_search
{
“query”:{
“match”:{
“title”:“ES tutorial”
}
},
“sort”:[
{
“<列名>”:{
“order”:“<增序asc&&倒序desc>”
}
}
]
}
size分页
GET /index/type/_search
{
“query”:{
“match”:{
“title”:“ES tutorial”
}
},
“sort”:[
{
“<列名>”:{
“order”:“<增序asc&&倒序desc>”
}
}
]
“from”:0,(从第几个数据开始)
“size”:2(每页多少数据)
}
_source返回指定字段
GET /index/type/_search
{
“query”:{
“match”:{
“title”:“ES tutorial”
}
},
“sort”:[
{
“<列名>”:{
“order”:“<增序asc&&倒序desc>”
}
}
]
“_source”:[“<指定字段名>”,“<指定字段名>”]
}
查询操作命令
匹配所有查询
POST /index/_search{
“query”:{
“match_all”:{}
}
}
搜索response_code包含200(?pretty表示数据格式化,更好的展示)
POST /index/_search?pretty{
“query”:{
“match”:{
“response_code”:“200”
}
}
}
搜索response_code包含200或者100
POST /index/_search?pretty{
“query”:{
“match”:{
“response_code”:“200 100”
}
}
}
搜索response_code包含200并且包含100
POST /index/_search?pretty{
“query”:{
“match”:{
“response_code”:{
“query”:“200 100”
“operator”:“and”
}
}
}
}
搜索response_code包含200 100中超过50%以上比例的
POST /index/_search?pretty{
“query”:{
“match”:{
“response_code”:{
“query”:“200 100”
“minimum_should_match”:“50%”
}
}
}
}
多条件搜索
&&使用must,搜索response_code包含200并且response_name包含"a"
POST /index/_search?pretty{
“query”:{
“bool”:{
“must”:[{
“match”:{
“response_code”:“200”
}},{
“match”:{
“response_name”:“a”
}
}]
}
}
}
||使用should,搜索response_code包含200或者response_name包含"a"
POST /index/_search?pretty{
“query”:{
“bool”:{
“should”:[{
“match”:{
“response_code”:“200”
}},{
“match”:{
“response_name”:“a”
}
}]
}
}
}
搜索response_code包含200并且response_name不包含"a"
POST /index/_search?pretty{
“query”:{
“bool”:{
“must”:[{
“match”:{
“response_code”:“200”
}}],
“must_not”:[{
“match”:{
“response_name”:“a”
}
}]
}
}
}
范围查询(gte大于等于;gt大于;lte小于等于;lt小于)
查询response_code字段数值大于等于200
POST /index/_search?pretty{
“query”:{
“range”:{
“must”:{
“response_code”:{
“gte”:“200”
}
}
}
}
}
统计数量_count
POST /index/_count?pretty{
“query”:{
“match_all”:{}
}
}
修改数据
POST /index/type/id{
“<修改列>”:“<修改值>”,
“<修改列>”:“<修改值>”
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值