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

日志检索场景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 dayfrom car group by day;
http://www.lryc.cn/news/251438.html

相关文章:

  • 【高效开发工具系列】jackson入门使用
  • 深入理解网络非阻塞 I/O:NIO
  • Hdoop学习笔记(HDP)-Part.07 安装MySQL
  • [数据结构]HashSet与LinkedHashSet的底层原理学习心得
  • 使用unity开发Pico程序,场景中锯齿问题
  • Spring | Spring的基本应用
  • 项目开发维护技术文档(梳理总结中)
  • 【接口测试】Apifox实用技巧干货分享
  • 车联网架构设计(一)_消息平台的搭建
  • (蓝桥杯)1125 第 4 场算法双周赛题解+AC代码(c++/java)
  • 也可Adobe Animate
  • 【面试HOT200】回溯篇
  • JVM——内存溢出和内存泄漏
  • 《凤凰项目》读书笔记
  • 熬夜会秃头——beta冲刺Day4
  • HTML5+CSS3+Vue小实例:浪漫的心形文字动画特效
  • 数据结构-基数排序
  • 基于ASP.NET MVC技术的图书管理系统的设计与实现
  • C++17中的结构化绑定
  • Mover Creator 用户界面
  • 『Nginx安全访问控制』利用Nginx实现账号密码认证登录的最佳实践
  • MongoDB导入导出命令
  • 软件工程期末复习(1)
  • nextjs入门
  • 【C语言】字符串函数strlen #strcpy #strcmp #strcat #strstr及其模拟实现
  • 递归实现组合型枚举
  • SCAU:1065 数组中的指针
  • 找不到msvcp110.dll如何修复?分享5个亲测有效的修复方法
  • LeetCode刷题笔记第80题:删除有序数组中的重复项 II
  • 【开源存储】minio对象存储部署实践