插入一条数据
PUT /pos_bill/_doc/001?routing=abc
{
"billDate" : "20230715",
"billSerialNumber" : "0001",
"billType" : "601",
"source":"2",
"createTime" : "20230715143000"
}
其中pos_bill为表名,001为id,routing根据表的mapping,mapping中有routing则添加,没有则不添加
查询一条数据
GET /pos_bill/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"shopId": {
"value": "1FD902S84"
}
}
}
]
}
}
}
删除一条数据
POST gag_daily_bill_info/_delete_by_query
{
"query": {
"term": {
"_id": "77FCA5C399FA9E74F048AD8A131D8BE5"
}
}
}
修改一条数据
post /merchant_datasource_daily_data/_update/0001?routing=1FGIGMH01QLK
{
"doc":{
"isELeMeChannel" : "1",
"isMeiTuanAuth" : "1",
"isMeiTuanChannel" : "1",
"iso2oAuth" : "1",
"iso2oChannel" : "1"
}
}
取某个字段的和
GET /benchmark_merchant_daily_data/_search
{
"size": 0,
"aggs": {
"totalAmount": {
"sum": {
"field": "receivableAmount"
}
},
"数量": {
"sum": {
"field": "collectSalesTotal"
}
}
},
"query": {
"bool": {
"must": [
{
"term": {
"shopEntityId": {
"value": "1FGIHNM3QRP"
}
}
}
]
}
}
}
其中 "size": 0,为表中展示几条原有数据;aggs下面的俩sum为两个字段各自的和
只展示某些字段
{
"size": 1000,
"_source" : {
"includes" : [ "_id","benchNetAmount",problemLocatingStatus"],
"excludes" : [ ]
},
"query": {
"bool": {
"must": [
{
"term": {
"shopId": {
"value": "S244"
}
}
}
]
}
}
}
其中_source下的includes为展示的字段,excludes为不展示的字段
分组查询
GET /ads_sale_manage_shop_info_f/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"country": {
"value": "000001"
}
}
]
}
},
"aggs": {
"group1": {
"terms": {
"size": 10,
"field": "cont_no"
}
}
}
}
查询某个时间段内的数据
GET /bill_transaction_detail_prod/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"saleDate": {
"from": "2023-06-19",
"to": "2023-06-25"
}
}
}
]
}
}
}
查询时,某个字段为数组中的一个
GET /gag_business_circles_pay_info/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"shopEntityId": {
"value": "1FGIHNM3QRPBTT725C889LSKTH001574"
}
}
},
{
"terms": {
"type": ["1","2"]
}
}
]
}
}
}
查询不匹配
GET /shop_entity_sale_static/_search
{
"query": {
"bool": {
"must_not": [
{
"term": {
"shopEntityId": "S00017244"
}
}
]
}
}
}
查询字段缺失
GET /my_index/_search
{
"query": {
"bool": {
"must": [
{"missing": {"field": "age"}}
],
"must_not": [
{
"term": {
"shopEntityId": "S00017244"
}
}
]
}
}
}
查询某个字段存在
GET /my_index/_search
{
"query": {
"bool": {
"must": [
{"exists": {"field": "title"}}
],
"must_not": [
{
"term": {
"title": "good"
}
}
]
}
}
}