es操作流程

#创建(index,相当于database)basic-info
PUT basic-info

#插入(emp_info相当于原来的type,es7.0+ 无type)
POST basic-info/emp_info
{“age”:23,“birthday”:null,“businessModel”:null,“cardNo”:“110101200903074013”,“cardType”:1,“courierCode”:“9995”,“cpCode”:“100006”,“cpType”:null,“createTime”:1610419106000,“createUser”:“admin”,“createUserCode”:null,“departmentCode”:“JJQQKK001”,“departmentName”:null,“education”:null,“empCode”:null,“empId”:1217430,“empJobId”:1774936,“empType”:1,“gender”:1,“hiredate”:1609948800000,“industryMobile”:null,“jobCode”:“JJ100086001”,“jobLevel”:null,“jobName”:null,“jobType”:null,“leavingDate”:null,“lockingTime”:null,“nativePlace”:“台儿庄地铁站”,“networkName”:null,“nickName”:“超级赛亚人”,“operatorPassword”:null,“orgId”:null,“phoneNo”:“13536744100”,“positiveDate”:1609948800000,“realName”:“贝吉塔”,“source”:0,“updateTime”:1610420321000,“updateUser”:“admin”,“updateUserCode”:null,“userpass”:null,“workingState”:0,“zkostl”:null,“zkostlName”:null}

GET basic-info/emp_info/1

POST /basic-info/emp_info
{
“properties” : {
“id”:{“type”:“Integer”},
“emp_id”:{“type”:“Integer”},
“emp_job_id”:{“type”:“Integer”},
“cp_code”:{“type”:“text”},
“real_name”:{“type”:“text”},
“nick_name”:{“type”:“text”},
“emp_code”:{“type”:“text”},
“source”:{“type”:“Integer”},
“working_state”:{“type”:“Integer”},
“hiredate”:{“type”:“date”,“format”:“dateOptionalTime”},
“leaving_date”:{“type”:“date”,“format”:“dateOptionalTime”},
“locking_time”:{“type”:“datetime”,“format”:“dateOptionalTime”},
“department_code”:{“type”:“text”},
“job_code”:{“type”:“text”},
“card_no”:{“type”:“text”},
“card_type”:{“type”:“Integer”},
“gender”:{“type”:“Integer”},
“age”:{“type”:“Integer”},
“phone_no”:{“type”:“text”},
“native_place”:{“type”:“text”},
“create_time”:{“type”:“datetime”,“format”:“dateOptionalTime”},
“create_user”:{“type”:“text”},
“update_time”:{“type”:“datetime”,“format”:“dateOptionalTime”},
“update_user”:{“type”:“text”},
“positive_date”:{“type”:“date”,“format”:“dateOptionalTime”},
“courier_code”:{“type”:“text”},
“emp_type”:{“type”:“Integer”}
}
}

POST basic-info/emp_info
{“age”:23,“birthday”:null,“businessModel”:null,“cardNo”:“110101200903074013”,“cardType”:1,“courierCode”:“9995”,“cpCode”:“100006”,“cpType”:null,“createTime”:1610419106000,“createUser”:“admin”,“createUserCode”:null,“departmentCode”:“JJQQKK001”,“departmentName”:null,“education”:null,“empCode”:null,“empId”:1217430,“empJobId”:1774936,“empType”:1,“gender”:1,“hiredate”:1609948800000,“industryMobile”:null,“jobCode”:“JJ100086001”,“jobLevel”:null,“jobName”:null,“jobType”:null,“leavingDate”:null,“lockingTime”:null,“nativePlace”:“台儿庄地铁站”,“networkName”:null,“nickName”:“超级赛亚人”,“operatorPassword”:null,“orgId”:null,“phoneNo”:“13536744100”,“positiveDate”:1609948800000,“realName”:“贝吉塔”,“source”:0,“updateTime”:1610420321000,“updateUser”:“admin”,“updateUserCode”:null,“userpass”:null,“workingState”:0,“zkostl”:null,“zkostlName”:null}

#根据id获取数据
GET basic-info/emp_info/-IsVjXgBNxyPi05eILuC

#查询 index下所有数据
GET basic-info/emp_info/_search

#范围-查询条件
GET basic-info/emp_info/_search
{
“query”:{
“range”: {
“age”: {
“gte”: 40,
“lt”: 30
}
}
}
}

GET basic-info/emp_info/_search
{
“query”: {
“prefix”: {
“realName”: “贝贝”
}
}
}
#单个条件-查询
GET basic-info/emp_info/_search
{
“query”: {
“prefix”: {
“realName”: “贝”
}
}
}

###########################################执行下方数据需先删除原有的type=emp_info############################################

#保存数据-
POST basic-info/emp_info/1
{
“id”:1,
“age”:21,
“name”:“Jack”,
“password”:“a123456”
}

#取值
GET basic-info/emp_info/2

存在修改,不存在创建(先删除在创建)

POST basic-info/emp_info/2
{
“age” : 25,
“name”: “Staves”
}

取值(_source只看源数据)

GET basic-info/emp_info/1

#删除
DELETE basic-info
#获取所有文档
GET _search

分页查询

和SQL使用 LIMIT 关键字返回只有一页的结果一样,Elasticsearch接受 #from 和 size 参数:

#size : 每页条数,默认 10
#from : 跳过开始的结果数,默认 0

GET _search?size=2&from=10

POST /basic-info/emp_info
{
“properties” : {
“id” : {“type” : “long”},
“name” : {“type” : “text”},
“password” : {“type” : “text”},
“age” : {“type” : “integer”}
}
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值