[FEATURE] Expose total matched row count in PPL query response

未关闭
#5,895 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@ahkcs 已经在做这个了。

开始于 2026年10月20日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
java, sql
领域
api, backend

调研方向

Start by tracing how PPL query results and response metadata are built, then compare that path with the Query DSL response's total-hit handling. The issue does not name files or tests, so first locate the PPL response entry point and its tests. Done means the response exposes total matched rows separately from returned rows, with coverage for capped results.

由索引模型根据 Issue 内容生成。

描述

feature PPL

Is your feature request related to a problem?

A PPL query response reports only the rows it returns — the result's total and its row count are always the same. There is no way for a client to tell whether more rows matched than were returned.

This becomes a problem when a consumer caps the output. In the OpenSearch MCP server, PPLQueryTool now limits returned rows (by appending | head <size>) to avoid flooding an LLM's context window — see opensearch-mcp-server-py#327. The LLM knows the size cap it requested, but it has no signal that the underlying query matched more rows, so it cannot make an informed decision about whether to widen the request. The investigation can silently proceed on a partial view.

Query DSL does not have this gap: a _search response returns hits.total.value, which acts as a hint that the returned hits are a partial slice of a larger match. PPL has no equivalent.

What solution would you like?

Have the PPL response carry the total number of matched rows as a distinct value from the number of rows returned — for example in the response metadata or a dedicated field — so a client can detect that a result was truncated and decide whether to fetch more. This mirrors the role hits.total.value plays for Query DSL.

What alternatives have you considered?

  • Running a separate ... | stats count() query to get the total. This doubles the round-trips and cost, and the two queries can race against ongoing writes.
  • Relying on the client/LLM to always request a large enough size. This defeats the purpose of capping output and still gives no truncation signal.

Do you have any additional context?

Downstream consumer: opensearch-mcp-server-py#327 (PPLQueryTool size cap). Reviewer feedback on that PR raised that a capped PPL result gives the LLM no way to know more data exists, unlike Query DSL's total hits — which is what motivated this request.

主要语言
Java
星标
176
派生
237
平均合并
2 天 12 小时
30 天内合并 PR
34

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

opensearch-project/sql 的其他 Issue

查看 opensearch-project/sql 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。