Skip to content

fix(engine): Painless doc['field'].value has no date accessor methods - #51

Merged
xerj-org merged 1 commit into
xerj-org:mainfrom
Vinz2168:fix/painless-date-value-methods
Jul 27, 2026
Merged

fix(engine): Painless doc['field'].value has no date accessor methods#51
xerj-org merged 1 commit into
xerj-org:mainfrom
Vinz2168:fix/painless-date-value-methods

Conversation

@Vinz2168

Copy link
Copy Markdown
Collaborator

Summary

doc['a_date_field'].value returns the raw ISO-8601 string as a plain Painless String, so any date accessor method chained onto it (.getHour(), .getDayOfWeek(), etc. — the standard Painless/Java ZonedDateTime API real Elasticsearch exposes there) fell through to the generic "unsupported member access" error, and the whole script silently failed. This blocks any Kibana visualization whose bucket or metric dimension is a date-component script — most visibly the sample "Heat Map" visualization, which buckets its Y-axis by doc['timestamp'].value.getHour().

Fix

When one of the common date-accessor getters (getHour, getMinute, getSecond, getDayOfMonth, getMonthValue, getYear, getDayOfWeek) is called on a String value, parse it as a date via the same parser aggregations already use for date fields (aggs::parse_date_ms) and extract the requested UTC component. A string that isn't a parseable date (or a getter outside this set) still falls through unchanged to the existing unsupported-member error — this only adds a narrow, additive dispatch, it doesn't change how any other String method resolves.

Paired with #50 (terms aggregation script support), this fully unblocks the sample Heat Map visualization's date-script Y-axis end to end.

Test plan

  • cargo build --release -p xerj-api -p xerj-engine -p xerj-server
  • cargo fmt --check / cargo clippy --no-deps -- -D warnings — clean
  • Full ES-compat YAML conformance suite: 1360 passed, 0 failed, 3 skipped — no regressions
  • Manual verification: doc['timestamp'].value.getHour() via script_fields now returns the correct UTC hour (5, 14, 14 for three test timestamps) instead of silently producing no fields output

🤖 Generated with Claude Code

`doc['a_date_field'].value` returned the raw ISO-8601 string as a
plain Painless String, so any date accessor method chained onto it
(`.getHour()`, `.getDayOfWeek()`, etc. -- the standard Painless/Java
ZonedDateTime API real Elasticsearch exposes there) fell through to
the generic "unsupported member access" error and the whole script
silently failed. This blocks any Kibana visualization whose bucket
or metric dimension is a date-component script -- most visibly the
sample "Heat Map" visualization, which buckets its Y-axis by
`doc['timestamp'].value.getHour()`.

Fix: when a getter from the common date-accessor set (getHour,
getMinute, getSecond, getDayOfMonth, getMonthValue, getYear,
getDayOfWeek) is called on a String value, parse it as a date via
the same parser aggregations already use for date fields
(`aggs::parse_date_ms`) and extract the requested UTC component. A
string that isn't a parseable date (or a getter outside this set)
still falls through unchanged to the existing unsupported-member
error -- this only adds a narrow, additive dispatch, it doesn't
change how any other String method resolves.

Combined with the terms-aggregation script fix (separate PR), this
fully unblocks the sample Heat Map visualization's date-script
Y-axis end to end.

Verified: `doc['timestamp'].value.getHour()` via script_fields now
returns the correct UTC hour (5, 14, 14 for three test timestamps)
instead of silently producing no `fields` output. Full ES-compat
YAML conformance suite: 1360 passed, 0 failed, 3 skipped -- no
regressions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016XJaZygeuRfZfUg2B8tPKU
@xerj-org
xerj-org merged commit 550ffe7 into xerj-org:main Jul 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants