本文介绍: 指定字段必须存在或不存在。//自定字段去重查询
查询指定id信息
GET /index_name/_doc/1074266245


查询指定信息并降序
GET /index_name/_search
{
  "query": {
    "term": {
      "deviceId": {
        "value": "1074266245"
      }
    }
  }, 
  "sort": [
    {
      "timestamp": {
        "order": "desc"
      }
    }
  ]
}



//多条件查询
GET /index_name/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "payload.locator_dev_id": {
              "value": 100902
            }
          }
        },
        {
          "term": {
            "payload.dev_id": {
              "value": 100301
            }
          }
        }
      ]
    }
  },
  "sort": [
    {
      "timestamp": {
        "order": "desc"
      }
    }
  ]
}
//自定字段去重查询
GET /index_name/_search
{
    "query": {
    "term": {
      "bodyObj.payLoad.dev_id": {
        "value": "100101"
      }
    }
    },
    "collapse": {
        "field": "bodyObj.payLoad.key"
    },
    "from": 0,
    "size": 10,
    "track_total_hits": true,
    "aggs": {
      "courseAgg": {
        "cardinality": {
          "field": "bodyObj.payLoad.key"
        }
      }
    }
}
//修改指定字段值
POST /index_name/_update/101202
{
  "doc": {
    "category":"2"
  }
}

#指定字段必须存在或不存在
GET /index_name/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "exists": {
            "field": "deviceId"
          }
        }
      ]
    }
  },
  "sort": [
    {
      "timestamp": {
        "order": "desc"
      }
    }
  ]
}

原文地址:https://blog.csdn.net/nsa65223/article/details/130952797

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_43822.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注