1.查询存在该字段的数据
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "chainCode"
}
}
]
,
"must_not": {
"exists": {
"field": "isDelete"
}
}
}
}
}
备注:存在chainCode 的字段并且不存在isDelete的资源
2.删除id(LxcAjXD2bS1)数据中的chainCode字段
{
"query": {
"term": {
"id.keyword": "LxcAjXD2bS1"
}
},
"script": {
"source": "ctx._source.remove('chainCode')"
}
}
3.查询es 中的条数
/hotel/_count
{
"query": {
"bool": {
"must": [
{
"term": {
"isDelete": {
"value": false
}
}
}
]
}
}
}
4.查询map数据中存在某一个值的数据
code 的结构
"code": {
"108": "42981"
}
{
"query":{
"bool" : {
"must" : [
{
"term" : {
"code.108.keyword" : {
"value" : "42921",
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
}
5.更新es 数据
{
"query": {
"term": {
"id.keyword": "9988971080"
}
},
"script": {
"source": "ctx._source.code = params.code",
"params": {
"code": {
"106": "9016003",
"108": "9989719",
"103": "H1460832"
}
}
}
}
6.es 只返回某些具体的字段
{
"_source": ["hotelName.value", "code.108", "address.value", "phone.value", "district.value", "priceUpdateTime"],
"query": {
"bool": {
"must": [
{
"exists": {
"field": "code.108"
}
}
]
}
},
"sort": [
{
"priceUpdateTime": {
"order": "desc"
}
}
],
"size": 1000,
"from": 0
}
7.track_total_hits查询数据的条数
{
"query": {
"term": {
"isDelete": true
}
},
"track_total_hits": true
}
8.通过ID查询具体的某一条数据
{
"query": {
"term": {
"id.keyword": "xZgr7KPlu"
}
}
}