From cccef6a7cefe398591c6a825cc5da801e7e53faa Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Thu, 11 Sep 2014 12:52:58 +0200 Subject: [PATCH] [DOCS] Additional documentation for _score accessing Closes #7043 Conflicts: docs/reference/modules/scripting.asciidoc --- docs/reference/modules/scripting.asciidoc | 12 +++++++++--- .../metrics/tophits-aggregation.asciidoc | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/reference/modules/scripting.asciidoc b/docs/reference/modules/scripting.asciidoc index 67fabdb154fda..8bb7985c22f3e 100644 --- a/docs/reference/modules/scripting.asciidoc +++ b/docs/reference/modules/scripting.asciidoc @@ -302,9 +302,8 @@ There are a few limitations relative to other script languages: [float] === Score -In all scripts that can be used in facets, the current -document's score is accessible in `doc.score`. When using a `script_score`, -the current score is available in `_score`. +In all scripts that can be used in aggregations, the current +document's score is accessible in `_score`. [float] === Computing scores based on terms in scripts @@ -408,6 +407,13 @@ are much slower to access compared with document fields, as they are not loaded into memory. They can be simply accessed using `_fields['my_field_name'].value` or `_fields['my_field_name'].values`. +[float] +=== Accessing the score of a document within a script + +When using scripting for calculating the score of a document (for instance, with +the `function_score` query), you can access the score using the `_score` +variable inside of a Groovy script. + [float] === Source Field diff --git a/docs/reference/search/aggregations/metrics/tophits-aggregation.asciidoc b/docs/reference/search/aggregations/metrics/tophits-aggregation.asciidoc index 95a1b1a0c2992..d4978619521ae 100644 --- a/docs/reference/search/aggregations/metrics/tophits-aggregation.asciidoc +++ b/docs/reference/search/aggregations/metrics/tophits-aggregation.asciidoc @@ -184,7 +184,7 @@ relevancy order of the most relevant document in a bucket. }, "top_hit" : { "max": { - "script": "_doc.score" + "script": "_score" } } }