当前位置: 首页 > article >正文

日志检索场景ES->Doris迁移最佳实践:函数篇

函数列表

  1. 函数:term
  2. 函数功能说明:查询某个字段里含有某个关键词的文档
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
  "query": {
    "term": {
      "title":   "blog"
    }
  }
}
  1. Doris使用示例:
select * from httplogs where title = 'blog';

  1. 函数:terms
  2. 函数功能说明:查询某个字段里含有多个关键词的文档
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
  "query": {
    "terms": {
      "title":  [ "blog","page"]
    }
  }
}
  1. Doris使用示例:
select * from httplogs where title IN ('blog', 'page');

  1. 函数:match
  2. 函数功能说明:match首选对字段进行分词操作,然后再查询
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
  "query": {
    "match": {
      "title":  "blog page"   
    }
  }
}

说明:和term区别可以理解为term是精确查询,这边match模糊查询;match会对my ss分词为两个单词,然后term对认为这是一个单词
5. Doris使用示例:

 select * from httplogs where request MATCH 'blog page';

  1. 函数:should
  2. 函数功能说明:至少有一个查询条件匹配
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
"bool": {
"should": [
      { "term": { "title": "error" }},
      { "term": { "title": "exption" }} ]
  }
}
  1. Doris使用示例:
select * from httplogs where title = 'error' or  title = 'exption';

  1. 函数:must
  2. 函数功能说明:查询指定文档一定要被包含
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
  "query": {
    "bool": {
      "must": [
        {"match": {
          "title": "page"
        }},
        {
          "match": {
            "content": "beijing"
          }
        }
      ]
    }
  }
}
  1. Doris使用示例:
select * from httplogs where title MATCH 'title' and  content MATCH 'exption';

  1. 函数:must not
  2. 函数功能说明:
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
  "query": {
    "bool": {
      "must_not": [
        {"match": {
          "title": "page"
        }},
        {
          "match": {
            "content": "beijing"
          }
        }
      ]
    }
  }
}
  1. Doris使用示例:
select * from httplogs where 
!(title MATCH 'title') 
and  !(content MATCH 'exption');

  1. 函数:exists
  2. 函数功能说明:查找文档中是否包含指定字段或没有某个字段
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
  "query": {
    "exists": { 
      "field": "title"
    }
  }
}
  1. Doris使用示例:
select * from httplogs where title IS NOT NULL;

  1. 函数:sum
  2. 函数功能说明:
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
{
  "aggs": {
    "hat_prices": { "sum": { "field": "price" } }
  }
}
  1. Doris使用示例:
select sum(price) from example_table

  1. 函数:date_histogram
  2. 函数功能说明:按照日期时间聚合分析数据
  3. 参数说明:
  4. 返回值说明:
  5. ES使用示例:
    GET cars/index/_search
{
  "size":0,
  "aggs": {
    "sales": {
      "date_histogram": {//按照日期时间聚合分析数据
        "field": "event_time",//分组字段
        "interval": "1d",//安天分组
        "format": "yyyy-MM-dd",//日期格式
        "min_doc_count": 0// 没有数据的日志返回0
      }
    }
  }
}
  1. Doris使用示例:
select DAY_FLOOR(event_time) as day
 from car group by day;

http://www.kler.cn/news/156368.html

相关文章:

  • Python+OpenCV实现最强自动扫雷
  • 算法基础--双指针
  • 深度学习——第3章 Python程序设计语言(3.2 Python程序流程控制)
  • PAD平板签约投屏-高端活动的选择
  • C++基础介绍及关键字
  • PHPExcel 导出Excel报错:PHPExcel_IOFactory::load()
  • 分享74个节日PPT,总有一款适合您
  • 【部署】Deploying Trino on linux
  • C++ string类(2)—成员访问、插入、删除、替换、查找和交换操作
  • 免费数据采集软件,多种数据采集方式
  • centos 源码编译gcc10.2
  • Vue框架学习笔记——列表渲染:v-for
  • python——多线程的相关知识点总结
  • Golang数据类型(数字型)
  • 风变科技千万营收的AIGC项目,在Fanbook成功落地,专访风变科技CMO江育麟
  • 创建Asp.net MVC项目实现视图页面数据传值显示
  • leetCode 39.组合总和 + 回溯算法 + 剪枝 + 图解 + 笔记
  • minio服务端搭建使用
  • 智能手表上的音频(四):语音通话
  • ROS-ROS通信机制-话题通信
  • 免费的SEO外链发布工具,提升排名的利器
  • springboot集成springsecurity
  • Web3之L2 ZK-Rollup 方案-StarkNet
  • 怎样使用rtsp,rtmp摄像头低延时参于Web视频会议互动直播
  • 网工学习9-STP配置(二)
  • 抖音直播间自动发言评论软件:开发技术分析与核心代码分享
  • 二、DVP摄像头调试笔记(dvp外设驱动篇、寄存器篇)
  • js选中起始时间使用标准时间毫秒值计算一年后的当前少一天的日期(并考虑闰年)
  • 【拓展】Loguru:更为优雅、简洁的Python 日志管理模块
  • COMP4121Advanced Algorithms