大家好,又见面了,我是你们的朋友全栈君。
ES增删改查
一:结构操作
1.查询对应索引的表结构
GET biz_commission_book
2.创建表
复制代码
PUT cfg_send_sku
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"cfg_send_sku" : {
"properties" : {
"obdCode" : {
"type" : "keyword"
},
"skuNo" : {
"type" : "keyword"
},
"skuName" : {
"type" : "keyword"
},
"weight" : {
"type" : "double"
},
"volume" : {
"type" : "double"
},
"cartonNumbers" : {
"type" : "integer"
},
"factory" : {
"type" : "keyword"
},
"batchNo" : {
"type" : "keyword"
},
"commissionBookNumber" : {
"type" : "keyword"
},
"tenantCode" : {
"type" : "keyword"
},
"createUser" : {
"type" : "keyword"
},
"createTime" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"updateUser" : {
"type" : "keyword"
},
"updateTime" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"isDelete" : {
"type" : "integer"
}
}
}
}
}
复制代码
3.增加字段
复制代码
PUT biz_commission_book/_mapping/biz_commission_book
{
"properties":{
"carrierCode" : {
"type" : "keyword"
},
"carrierName" : {
"type" : "keyword"
},
"transCapType" : {
"type" : "integer"
}
}
}
复制代码
4、删除索引
DELETE /cfg_zx
二:数据操作
1.增加数据 14 代表ID
复制代码
PUT iot_vehicle_biz_case/biz_case/14
{
"vehicleNo" : "皖AA1227",
"caseProperties" : 1,
"orgNameV" : "总机构",
"orgCodeV" : "001",
"caseStatus" : 2,
"caseId" : "88888",
"caseSubType" : 1,
"caseTime" : "2020-11-25 18:37:00",
"caseLevel" : 1,
"tenantCode" : "lestore_web",
"vehicleAlias" : "666666",
"interests": [ "sports", "music" ],
"caseType" : 1
}
复制代码
2.删除
2.1删除所有
_delete是删除命令
复制代码
GET cfg_send_sku/cfg_send_sku/_delete_by_query
{
"query": {
"match_all": {
}
}
}
复制代码
2.2删除指定条件
复制代码
GET cfg_send_sku/cfg_send_sku/_delete_by_query
{
"query": {
"match": {
"skuName":"大白兔奶糖"
}
}
}
复制代码
3.更新
3.1更新某个字段的值
复制代码
#JyrzKnUBgCgVdP2UH0aa指的是id
POST biz_commission_book/biz_commission_book/JyrzKnUBgCgVdP2UH0aa/_update
{
"doc": {
"transCapType":1
}
}
复制代码
4.查询
4.1查询所有
cfg_send_sku是索引名,cfg_send_sku是索引类型,_search是固定后缀,是查询命令。本例子是查询所有
复制代码
GET cfg_send_sku/cfg_send_sku/_search
{
"query":
{
"match_all": {
}
}
}
复制代码
4.2查询指定
复制代码
GET cfg_send_sku/cfg_send_sku/_search
{
"query": {
"match": {
"skuName":"大白兔奶糖"
}
}
}
复制代码
4.3查询多个字段
复制代码
GET biz_commission_book/biz_commission_book/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"receiverNumber":"4695619"
}
},
{
"match": {
"truckingOrderNumber":"AS1598403676403696"
}
}
]
}
}
}
复制代码
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/130984.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...