# Elasticsearch 协议支持、倒排索引优化与性能提升，又被外部贡献者“卷”到了！| Greptime 双周精选

Source: https://greptime.cn/blogs/2025-01-22-biweekly-report

## 内容概述

作为一个成长中的开源项目，GreptimeDB 的进展离不开来自全球的社区贡献者们，感谢各位！

最近的更新内容如下：

- **支持 Elasticsearch 协议的日志写入**
- **支持使用 `ALTER` 来修改倒排索引**
- **引入稀疏主键编码来优化 Metrics 性能**
- **开始引入 BloomFilter 来作为全文索引的替代**

## 社区贡献者名单

在过去的两周里，GreptimeDB 共合并了 **113 个 PR**，其中有 **6 位独立贡献者**，累计 **23 个 PR** 被成功合并，还有很多待合并的 PR 。

祝贺以下各位在过去 2 周内成为我们最突出的贡献者：

- @[linyihai](https://github.com/linyihai) ([db#5303](https://github.com/GreptimeTeam/greptimedb/pull/5303))

- @[lyang24](https://github.com/lyang24) ([db#5131](https://github.com/GreptimeTeam/greptimedb/pull/5131))

- @[mtrbpr](https://github.com/mtrbpr) ([promql-parser#101](https://github.com/GreptimeTeam/promql-parser/pull/101))

- @[NiwakaDev](https://github.com/NiwakaDev) ([docs#1468](https://github.com/GreptimeTeam/docs/pull/1468) [db#5393](https://github.com/GreptimeTeam/greptimedb/pull/5393) [db#5383](https://github.com/GreptimeTeam/greptimedb/pull/5383) [db#5262](https://github.com/GreptimeTeam/greptimedb/pull/5262))

- @[Xuanwo](https://github.com/Xuanwo) ([db#5354](https://github.com/GreptimeTeam/greptimedb/pull/5354))

- @[yihong0618](https://github.com/yihong0618) ([db#5400](https://github.com/GreptimeTeam/greptimedb/pull/5400) [db#5388](https://github.com/GreptimeTeam/greptimedb/pull/5388) [db#5383](https://github.com/GreptimeTeam/greptimedb/pull/5383) [db#5363](https://github.com/GreptimeTeam/greptimedb/pull/5363) [db#5362](https://github.com/GreptimeTeam/greptimedb/pull/5362) [db#5352](https://github.com/GreptimeTeam/greptimedb/pull/5352) [db#5349](https://github.com/GreptimeTeam/greptimedb/pull/5349) [db#5342](https://github.com/GreptimeTeam/greptimedb/pull/5342) [db#5339](https://github.com/GreptimeTeam/greptimedb/pull/5339) [db#5329](https://github.com/GreptimeTeam/greptimedb/pull/5329) [db#5328](https://github.com/GreptimeTeam/greptimedb/pull/5328) [db#5325](https://github.com/GreptimeTeam/greptimedb/pull/5325) [db#5313](https://github.com/GreptimeTeam/greptimedb/pull/5313) [db#5311](https://github.com/GreptimeTeam/greptimedb/pull/5311) [db#5301](https://github.com/GreptimeTeam/greptimedb/pull/5301))

👏 欢迎 @[mtrbpr](https://github.com/mtrbpr) 作为新的贡献者加入到社区，并成功合并了 PR，还有更多来自其他独立贡献者的 PR 正在等待合并。

<figure>
<img src="/zh/blogs/2025-01-22-biweekly-report/image1.png" alt="（图 1：Greptime 新晋 Contributor）" style="width: 80%; margin: 0 auto"/>
<figcaption>（图 1：Greptime 新晋 Contributor）</figcaption>
</figure>

🎉 衷心感谢我们所有的成员和贡献者！是你们的付出让我们的项目得以成功，也是你们让 GreptimeDB 成为一个更优质的产品。让我们一起努力，建立一个更棒的社区！

## PR 亮点

### [db#5261 支持 Elasticsearch `_bulk` API 来写入日志](https://github.com/GreptimeTeam/greptimedb/pull/5261)

用户可使用 Elasticsearch `_bulk` API 或者 Logstash 来写入日志，进一步丰富了 GreptimeDB 对于日志生态的支持。

### [db#5131 支持使用 `ALTER` 来修改倒排索引](https://github.com/GreptimeTeam/greptimedb/pull/5131)

用户可使用 `ALTER` 命令来设置倒排索引，从而让索引的调整变得更加灵活简单。

### [db#5365 引入 `SparsePrimaryKeyCodec` 和 `SparsePrimaryKeyFilter`](https://github.com/GreptimeTeam/greptimedb/pull/5365)

在 Metrics 场景中，当物理表上的主键列数量变得过大时，编码所有主键所需的CPU开销显著增加。这导致写入和查询操作都出现了明显的性能瓶颈。

本 PR 引入稀疏主键来只编码 non-null 键，降低 CPU 开销来提升性能。

完整的 Trakcing Issue 可参考 [db#5282](https://github.com/GreptimeTeam/greptimedb/pull/5282)。

### [db#5406 开始引入 BloomFilter 来作为全文索引的替代](https://github.com/GreptimeTeam/greptimedb/pull/5406)

全文索引在日志的场景会带来极大的资源开销，为缓解这一情况，本 PR 开始使用 BloomFilter 来作为索引构建方式，从而可作为一种替换全文索引的方式。这种索引构建方式较之全文索引可极大减低资源开销。

## Good First Issue

### [db#5084 添加用于查询 Pipeline 的 HTTP API](https://github.com/GreptimeTeam/greptimedb/issues/5084)

尽管我们决定不为数据库暴露太多 HTTP API，但除了 Pipeline 的创建和删除操作之外，为 Pipeline 查询提供 HTTP API 是很自然的选择。

从开发者体验来看，当他们创建 Pipeline 时，使用类似的 API 来查询 Pipeline 会很方便，这样就不用通过 SQL 查询 `greptime_private`。例如：

```plaintext
curl -XGET "http://localhost:4000/v1/events/pipelines/test?db=public"
```

- **难度**: 简单

- **关键词**: 日志

## 关于 Greptime

[Greptime 格睿科技](https://greptime.cn/)专注于为可观测、物联网及车联网等领域提供实时、高效的数据存储和分析服务，帮助客户挖掘数据的深层价值。目前基于云原生的时序数据库 [GreptimeDB](https://github.com/GreptimeTeam/greptimedb) 已经衍生出多款适合不同用户的解决方案，更多信息或 demo 展示请联系下方小助手（微信号：greptime）。

欢迎对开源感兴趣的朋友们参与贡献和讨论，从带有 good first issue 标签的 issue 开始你的开源之旅吧～期待在开源社群里遇见你！添加小助手微信即可加入“技术交流群”与志同道合的朋友们面对面交流哦~

Star us on GitHub Now: https://github.com/GreptimeTeam/greptimedb

官网：https://greptime.cn/

文档：https://docs.greptime.cn/

Twitter: https://twitter.com/Greptime

Slack: https://greptime.com/slack

LinkedIn: https://www.linkedin.com/company/greptime/
