ElasticSearch查询指定时间内出现的次数/2秒内出现的次数

  1. 查询指定时间内出现的次数
json 复制代码
POST process-log/_search
{
    "size": 0,
    "query": {
        "bool": {
            "filter": [
                {
                    "range": {
                        "requestTime": {
                            "from": 1722470400000,
                            "to": 1722556800000
                        }
                    }
                }
            ]
        }
    },
    "aggs": {
        "server_request": {
            "terms": {
                "script": {
                    "source": "if (doc['serverName.keyword'].size() > 0 && doc['requestUri.keyword'].size() > 0) { return doc['serverName.keyword'].value + ' ' + doc['requestUri.keyword'].value; } else { return 'N/A'; }",
                    "lang": "painless"
                },
                "size": 10,
                "order": {
                    "_count": "desc"
                }
            }
        }
    }
}
  1. Elasticsearch 插叙2秒内出现的次数
java 复制代码
POST process-log/_search
{
  "size": 0,
  "query": {
    "bool": {
      "filter": {
        "range": {
          "requestTime": {
            "from": 1721692800000,
            "to": 1721952000000
          }
        }
      }
    }
  },
  "aggs": {
    "uri_over_time": {
      "composite": {
        "size": 100, 
        "sources": [
          {
            "requestTime": {
              "date_histogram": {
                "field": "requestTime",
                "fixed_interval": "2s"
              }
            }
          },
          {
            "requestUri": {
              "terms": {
                "field": "requestUri.keyword"
              }
            }
          },
          {
            "serverName": {
              "terms": {
                "field": "serverName.keyword"
              }
            }
          }
        ]
      }
    }
  }
}
相关推荐
极客数模3 小时前
【2026美赛赛题初步翻译F题】2026_ICM_Problem_F
大数据·c语言·python·数学建模·matlab
编程彩机6 小时前
互联网大厂Java面试:从分布式架构到大数据场景解析
java·大数据·微服务·spark·kafka·分布式事务·分布式架构
vx-bot5556666 小时前
企业微信接口在多租户SaaS平台中的集成架构与数据隔离实践
大数据·架构·企业微信
bubuly8 小时前
软件开发全流程注意事项:从需求到运维的全方位指南
大数据·运维·数据库
xixixi7777710 小时前
基于零信任架构的通信
大数据·人工智能·架构·零信任·通信·个人隐私
Hello.Reader11 小时前
Flink 自适应批执行(Adaptive Batch Execution)让 Batch 作业“边跑边优化”
大数据·flink·batch
LaughingZhu12 小时前
Product Hunt 每日热榜 | 2026-01-31
大数据·人工智能·经验分享·搜索引擎·产品运营
babe小鑫12 小时前
中专学历进入快消大厂终端销售岗位的可行性分析
大数据
samFuB12 小时前
【工具变量】区县5A级旅游景区DID数据集(2000-2025年)
大数据
百夜﹍悠ゼ12 小时前
数据治理DataHub安装部署
大数据·数据治理