From 9206b8cf646a797a019df6b9a56c39115a0150b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Mon, 10 Sep 2018 11:17:24 +0200 Subject: [PATCH 1/2] [Docs] Clarify accessing Date methods in painless I just tried to access the millis of a date field in painless and tried to use "getMillis" on the document value like `doc['event_date'].value.getMillis` because that is how I read the documentation. It turns out the way it works is `doc['event_date'].value.millis`. I might be missing something, but if not I think the docs are a bit misleading and could be corrected like suggested. --- docs/painless/painless-getting-started.asciidoc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/painless/painless-getting-started.asciidoc b/docs/painless/painless-getting-started.asciidoc index 8cff207ab04d5..d542fa472ee6b 100644 --- a/docs/painless/painless-getting-started.asciidoc +++ b/docs/painless/painless-getting-started.asciidoc @@ -198,13 +198,11 @@ POST hockey/player/1/_update ==== Dates Date fields are exposed as -`ReadableDateTime` or -so they support methods like -`getYear`, -and `getDayOfWeek`. -To get milliseconds since epoch call -`getMillis`. -For example, the following returns every hockey player's birth year: +`ReadableDateTime`, so they support methods like `getYear`, `getDayOfWeek` +or e.g. getting milliseconds since epoch with `getMillis`. To use these +in a script, leave out the `get` prefix and continue with lowercasing the +rest of the method nane. For example, the following returns every hockey +player's birth year: [source,js] ---------------------------------------------------------------- From 361dc72c76b76e79709b9f80654c1a86b82d4e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Mon, 10 Sep 2018 11:46:22 +0200 Subject: [PATCH 2/2] Update painless-getting-started.asciidoc --- docs/painless/painless-getting-started.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/painless/painless-getting-started.asciidoc b/docs/painless/painless-getting-started.asciidoc index d542fa472ee6b..4edd96787ddb2 100644 --- a/docs/painless/painless-getting-started.asciidoc +++ b/docs/painless/painless-getting-started.asciidoc @@ -201,7 +201,7 @@ Date fields are exposed as `ReadableDateTime`, so they support methods like `getYear`, `getDayOfWeek` or e.g. getting milliseconds since epoch with `getMillis`. To use these in a script, leave out the `get` prefix and continue with lowercasing the -rest of the method nane. For example, the following returns every hockey +rest of the method name. For example, the following returns every hockey player's birth year: [source,js]