From 46edfc484a513c0e567e9e55f38ca3ddce41292d Mon Sep 17 00:00:00 2001 From: Ben McCann Date: Sat, 2 Nov 2013 20:09:24 -0700 Subject: [PATCH] [DOCS] Add some documentation about the performance of `_source` usage in scripts. --- docs/reference/modules/scripting.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/reference/modules/scripting.asciidoc b/docs/reference/modules/scripting.asciidoc index 39dee1478b1..f0fda7e7ad2 100644 --- a/docs/reference/modules/scripting.asciidoc +++ b/docs/reference/modules/scripting.asciidoc @@ -184,6 +184,12 @@ source field is loaded per doc, parsed, and then provided to the script for evaluation. The `_source` forms the context under which the source field can be accessed, for example `_source.obj2.obj1.field3`. +Accessing `_source` is much slower compared to using `_doc` +but the data is not loaded into memory. For a single field access `_fields` may be +faster than using `_source` due to the extra overhead of potentially parsing large documents. +However, `_source` may be faster if you access multiple fields or if the source has already been +loaded for other purposes. + [float] === mvel Built In Functions