函数列表
- 函数:term
- 函数功能说明:查询某个字段里含有某个关键词的文档
- 参数说明:
- 返回值说明:
- ES使用示例:
{"query": {"term": {"title": "blog"}}
}
- Doris使用示例:
select * from httplogs where title = 'blog';
- 函数:terms
- 函数功能说明:查询某个字段里含有多个关键词的文档
- 参数说明:
- 返回值说明:
- ES使用示例:
{"query": {"terms": {"title": [ "blog","page"]}}
}
- Doris使用示例:
select * from httplogs where title IN ('blog', 'page');
- 函数:match
- 函数功能说明:match首选对字段进行分词操作,然后再查询
- 参数说明:
- 返回值说明:
- ES使用示例:
{"query": {"match": {"title": "blog page" }}
}
说明:和term区别可以理解为term是精确查询,这边match模糊查询;match会对my ss分词为两个单词,然后term对认为这是一个单词
5. Doris使用示例:
select * from httplogs where request MATCH 'blog page';
- 函数:should
- 函数功能说明:至少有一个查询条件匹配
- 参数说明:
- 返回值说明:
- ES使用示例:
{
"bool": {
"should": [{ "term": { "title": "error" }},{ "term": { "title": "exption" }} ]}
}
- Doris使用示例:
select * from httplogs where title = 'error' or title = 'exption';
- 函数:must
- 函数功能说明:查询指定文档一定要被包含
- 参数说明:
- 返回值说明:
- ES使用示例:
{"query": {"bool": {"must": [{"match": {"title": "page"}},{"match": {"content": "beijing"}}]}}
}
- Doris使用示例:
select * from httplogs where title MATCH 'title' and content MATCH 'exption';
- 函数:must not
- 函数功能说明:
- 参数说明:
- 返回值说明:
- ES使用示例:
{"query": {"bool": {"must_not": [{"match": {"title": "page"}},{"match": {"content": "beijing"}}]}}
}
- Doris使用示例:
select * from httplogs where
!(title MATCH 'title')
and !(content MATCH 'exption');
- 函数:exists
- 函数功能说明:查找文档中是否包含指定字段或没有某个字段
- 参数说明:
- 返回值说明:
- ES使用示例:
{"query": {"exists": { "field": "title"}}
}
- Doris使用示例:
select * from httplogs where title IS NOT NULL;
- 函数:sum
- 函数功能说明:
- 参数说明:
- 返回值说明:
- ES使用示例:
{"aggs": {"hat_prices": { "sum": { "field": "price" } }}
}
- Doris使用示例:
select sum(price) from example_table
- 函数:date_histogram
- 函数功能说明:按照日期时间聚合分析数据
- 参数说明:
- 返回值说明:
- 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}}}
}
- Doris使用示例:
select DAY_FLOOR(event_time) as dayfrom car group by day;