ElasticSearch学习笔记三:es kibana操作语句

索引基本操作

1.新建索引

PUT employees

2.新建mapping

POST /employees/_doc/_mapping

{

"properties": {

"birth_date": {

"type": "date",

"format": "yyyy-MM-dd HH:mm:ss"

},

"emp_no": {

"type": "long"

},

"first_name": {

"type": "text",

"fields": {

"keyword": {

"type": "keyword",

"ignore_above": 256

}

}

},

"gender": {

"type": "text",

"fields": {

"keyword": {

"type": "keyword",

"ignore_above": 256

}

}

},

"hire_date": {

"type": "date",

"format": "yyyy-MM-dd HH:mm:ss"

},

"last_name": {

"type": "text",

"fields": {

"keyword": {

"type": "keyword",

"ignore_above": 256

}

}

}

}

}

3.精确查询

GET /app/_doc/166

4.根据时间段查询

GET /app/_search

{

"size": 1,

"query": {

"bool": {

"must": [

{"range": {

"collect_time": {

"gte": "2020-06-01-20",

"lte": "2020-06-01-21",

"format": "yyyy-MM-dd-HH",

"time_zone":"+08:00"

}

}

}

]

}

}

}

1.查询全部数据

GET /test/_search

2.查询指定字段

GET /test/_search

{

"query": {

"match_all": {}

},

"_source": ["title","age"]

}

es集群操作

1.查看集群健康状态

curl -XGET 'http://localhost:9200/_cluster/health?pretty'

2.查看主节点

curl -XGET 'http://localhost:9200/_cluster/state/master_node,nodes?pretty'

3.停用集群中的节点

curl -XPUT http://localhost:9200/_cluster/settings -d '{

"transient" : {

"cluster.routing.allocation.exclude._ip" : "10.102.29.69"

}

}'

4.确定分片位置

curl -XGET 'http://localhost:9200/_cluster/state/routing_table,routing_nodes?pretty'

5.为索引创建别名

POST _aliases

{

"actions" : [{"add" : {"index" : "school" , "alias" : "in1"}}]

}

6.删除别名

POST _aliases

{

"actions" : [{"remove" : {"index" : "school" , "alias" : "in1"}}]

}

搜索数据

1.请求范围

/_search 全局搜索

/索引名/_search 根据索引搜索

/索引名/类型/_serach

/_all/类型/_search

/*/类型/_search

/索引1,索引2/类型1,类型2/_serach

 

2.###################基于URL的搜索######################

GET /app/_search?from=10&size=10

 

GET /app/_search?sort=collect_time:desc

 

GET /app/_search?sort=collect_time:desc&_source=ip,collect_time

 

GET /app/_search?sort=collect_time:desc&q=type:lettuce

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值