基本知识:es 基本信息查询

1.查询集群的基本运行状况-health
curl -XGET 'localhost:9200/_cat/health?v&pretty'
结果:
结果参数:
status:
  • Green - everything is good (cluster is fully functional)
  • Yellow - all data is available but some replicas are not yet allocated (cluster is fully functional)
  • Red - some data is not available for whatever reason (cluster is partially functional)
2.集群的节点信息
curl -XGET 'localhost:9200/_cat/nodes?v&pretty'

结果:
说明此时我们的集群只有一个名字为“node-1”的节点
3.集群 中的索引信息
curl -XGET 'localhost:9200/_cat/indices?v&pretty'
结果:
说明:我们集群中还没有建立index


说明:我们集群中有一个customer的index
4.查看插件安装是否成功:
结果:
5.创建index 和mapping
如下:直接创建了index和mapping(这个mapping是结构化的映射)

{
    "mapping":{
        "blogpost":{
            "properties":{
    
             "msg":{"type":"string","index":"not_analyzed"},
             
             "code":{"type":"integer","index":"not_analyzed"},
             
             "count":{"type":"integer","index":"not_analyzed"},
                
             "data":{
    
                       "type":"nested",
    
                       "properties":{
    
                                "type":{"type":"string","index":"not_analyzed"},
    
                                "user_name":{"type":"string","index":"not_analyzed"}
    
                       }
    
                }
    
            }
        }
    }

添加数据:

{"index":{"_index":"my_index","_type":"blogpost"}}
{"msg": "one","code": "00l","data": [{"type": "oracle", "user_name": "oracle2"},{"type": "mysql","user_name":"hive"}],"count": 1}
{"index":{"_index":"my_index","_type":"blogpost"}}
{"msg": "two","code": 0,"data": [{"type": "oracle", "user_name": "oracle2"},{"type": "mysql","user_name":"hive"}],"count": 2}
{"index":{"_index":"my_index","_type":"blogpost"}}
{"msg": "three","code": 0,"data": [{"type": "oracle", "user_name": "oracle2"},{"type": "mysql","user_name":"hive"}],"count": 3}
{"index":{"_index":"my_index","_type":"blogpost"}}
{"msg": "four","code": 0,"data": [{"type": "oracle", "user_name": "oracle2"},{"type": "mysql","user_name":"hive"}],"count": 4}

或者:

{"msg": "one","code": 0,"data": [{"type": "oracle", "user_name": "oracle2"},{"type": "mysql","user_name":"hive"}],"count": 1}


6.查看index下的type的mapping


7.ES Restful API GET、POST、PUT、DELETE、HEAD含义:  

1)GET:获取请求对象的当前状态。  
2)POST:改变对象的当前状态。  
3)PUT:创建一个对象。  
4)DELETE:销毁对象。  
5)HEAD:请求获取对象的基础信息。


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值