kibana 查询ES常用语法

GET test/_search
{
  "size": 6,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "title": "最好"
          }
        },
        {
          "exists": {
            "field": "author"
          }
        }
      ],
      "must_not": [
        {
          "match": {
            "title": "广场"
          }
        },
        {
          "match": {
            "author": ""
          }
        }
      ]
    }
  },
  "_source": [
    "title",
    "author",
    "cid",
    "ctype"
  ],
  "aggs": {
    "最小": {
      "min": {
        "field": "cid"
      }
    },
    "最大": {
      "max": {
        "field": "cid"
      }
    },
    "平均值": {
      "avg": {
        "field": "cid"
      }
    },
    "求和": {
      "sum": {
        "field": "cid"
      }
    },
    "去重count": {
      "cardinality": {
        "field": "ctype"
      }
    },
    "分组去重": {
      "terms": {
        "field": "ctype",
        "size": 10
      },
      "aggs": {
        "组内去重": {
          "cardinality": {
            "field": "ctype"
          }
        },
        "组内求和": {
          "sum": {
            "field": "cid"
          }
        }
      }
    }
  }
}

结果

{
  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 3.9180572,
    "hits": [
      {
        "_index": "huantv",
        "_type": "index_metadata",
        "_id": "0_96016",
        "_score": 3.9180572,
        "_source": {
          "ctype": 0,
          "author": "李婷",
          "title": "重庆最贵的小面,2两28元一碗!一大块牛肉炖的酥烂!",
          "cid": 96016
        }
      },
      {
        "_index": "huantv",
        "_type": "index_metadata",
        "_id": "0_95961",
        "_score": 3.7654238,
        "_source": {
          "ctype": 0,
          "author": "何三岁",
          "title": "内蒙最火的小吃!稍麦大坨肉面皮比纱还薄,羊油煎后美味升级!",
          "cid": 95961
        }
      }
    ]
  },
  "aggregations": {
    "去重count": {
      "value": 1
    },
    "最小": {
      "value": 95961
    },
    "平均值": {
      "value": 95988.5
    },
    "求和": {
      "value": 191977
    },
    "最大": {
      "value": 96016
    },
    "分组去重": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": 0,
          "doc_count": 2,
          "组内求和": {
            "value": 191977
          },
          "组内去重": {
            "value": 1
          }
        }
      ]
    }
  }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值