`es search --input-file` rejects the `sort` shorthand `[{"field":"asc"}]`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 63/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- json, typescript
- Ambito
- cli
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 53
- Fork
- 28
- Merge medio
- 23h 41m
- PR unite (30g)
- 44
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di elastic/cli
-
tracking
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
feat: ship skills/elastic/SKILL.md for agent invocationForse già presa @onatozmenn l’ha presa 32 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
elastic/cli#628 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elastic/cli#617 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
`es search --input-file` drops top-level `aggs` (and any unrecognised key) without an errorForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Shell: serve the home app's Cookie Policy on a hard reloadForse già presa @2001anshkaushik l’ha presa oggi. Apertafeature module:ai
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
rocketride-org/rocketride-server#2899 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
wazuh/wazuh-dashboard-plugins#9551 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
gofish-graphics/gofish-graphics#1252 ·
I maintainer di solito rispondono entro 1 giorno
-
optimization P3 size:XS
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
josephfung/curia#2366 ·
I maintainer di solito rispondono entro 1 giorno
-
stranded-follow-up sweep trusts any issue whose body carries the marker as the tracking issueApertatype:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
nightgauge/nightgauge#2688 ·
I maintainer di solito rispondono entro 1 giorno