`es search --input-file` rejects the `sort` shorthand `[{"field":"asc"}]`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 63/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- json, typescript
- 領域
- cli
調査の方向性
Start with the reproduction command using --input-file -, then read src/lib/json-schema-args.ts around lines 133-157 and src/factory.ts around lines 724-737 to see how unions are resolved and relaxed. Follow the sort value into _types__SortCombinations / _types__FieldSort from @elastic/schemas, then decide whether a CLI-side relaxation should mirror the existing object/array workaround or whether the schema fix must land upstream. Done means [{"@timestamp":"asc"}] passes validation for file-supplied bodies as it already does with --no-validate.
索引モデルが issue の本文から書いたものです。
説明
Summary
Elasticsearch accepts "sort":[{"@timestamp":"asc"}], the form used throughout its search docs. The CLI's client-side validation rejects it when the body comes from --input-file.
Reproduction (v0.7.0, also unchanged on main at fd3359d)
echo '{"size":1,"sort":[{"@timestamp":"asc"}]}' | elastic es search --index my-index --input-file -
# Error: input validation failed:
# ✖ must be string → at .sort
# ✖ must be object → at .sort
# ✖ must be string → at .sort[0]
# ✖ must be object → at .sort[0]['@timestamp']
# exit 1
Body sort |
CLI | Elasticsearch directly |
|---|---|---|
[{"@timestamp":"asc"}] |
validation error, exit 1 | OK |
[{"@timestamp":{"order":"asc"}}] |
OK | OK |
["@timestamp"] |
OK | OK |
shorthand with --no-validate |
OK | OK |
"@timestamp:asc" |
passes validation, then a shard failure (No mapping found for [@timestamp:asc]), HTTP 200, exit 0 |
same shard failure |
Sort shorthand nested inside a top_hits aggregation is accepted.
Mechanism
_types__SortCombinations in @elastic/schemas 0.10.0 accepts a string or _types__SortOptions. The additional properties of _types__SortOptions must be _types__FieldSort, which is an object, so the value "asc" fails. src/lib/json-schema-args.ts:133-157 resolves this union to the CLI string type, so the object/array relaxation in src/factory.ts:724-737 doesn't apply to a file-supplied sort.
Root cause
The schema is stricter than the specification. The spec marks FieldSort with @shortcut_property order (sort.ts L43-L44): a FieldSort may be written as just its order value. @elastic/schemas 0.10.0 emits _types__FieldSort as object-only, so "asc" fails.
The same loss affects 25 shortcut types in the spec, including term and match queries. Those pass in the CLI only because query is object-typed and covered by the relaxation described under Mechanism. sort isn't, so this is where the gap shows.
Reported upstream: elastic/schemas-js#125. A CLI-side workaround is to relax sort the same way, or to pass --no-validate, which already works. The schema fix covers every shortcut type.
Expected
Accept SortOrder strings ("asc" / "desc") as values in the sort object map, as the Elasticsearch spec does.
Related
- elastic/cli#330 and elastic/cli#350 fixed the
--sort field:directionflag. That flag works. This report is about the--input-filebody. - elastic/cli#331: a different field (
_sourcearrays) rejected by file-input validation.
- 主要言語
- TypeScript
- スター
- 53
- フォーク
- 28
- 平均マージ
- 23時間 41分
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
elastic/cli のほかの issue
-
tracking
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
feat: ship skills/elastic/SKILL.md for agent invocation対応中かも @onatozmenn が 32 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
`es search --input-file` drops top-level `aggs` (and any unrecognised key) without an error対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
lichess-org/lila#22324 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsオープンep:WebGPU platform:web quantization
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
microsoft/onnxruntime#33752 ·
メンテナーはふだん 2 日以内に返信
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimオープンbug entra-agent-id
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
fix(worker): keep normal prepare waiting states failure-free対応中かも @LichKing-2234 が今日担当しました。 オープンagent:codex priority:P1
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AgoraIO-Extensions/agent-infra#3745 ·
メンテナーはふだん 1 日以内に返信
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framing対応中かも @Eapp1e が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
makecindy/cindy#7973 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信