summaryrefslogtreecommitdiff
path: root/docs/groovy-api/index_.asciidoc
diff options
context:
space:
mode:
authorHilko Bengen <bengen@debian.org>2014-06-07 12:02:12 +0200
committerHilko Bengen <bengen@debian.org>2014-06-07 12:02:12 +0200
commitd5ed89b946297270ec28abf44bef2371a06f1f4f (patch)
treece2d945e4dde69af90bd9905a70d8d27f4936776 /docs/groovy-api/index_.asciidoc
downloadelasticsearch-d5ed89b946297270ec28abf44bef2371a06f1f4f.tar.gz
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'docs/groovy-api/index_.asciidoc')
-rw-r--r--docs/groovy-api/index_.asciidoc31
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/groovy-api/index_.asciidoc b/docs/groovy-api/index_.asciidoc
new file mode 100644
index 0000000..0e65a11
--- /dev/null
+++ b/docs/groovy-api/index_.asciidoc
@@ -0,0 +1,31 @@
+[[index_]]
+== Index API
+
+The index API is very similar to the
+{java}/index_.html[Java index API]. The Groovy
+extension to it is the ability to provide the indexed source using a
+closure. For example:
+
+[source,js]
+--------------------------------------------------
+def indexR = client.index {
+ index "test"
+ type "type1"
+ id "1"
+ source {
+ test = "value"
+ complex {
+ value1 = "value1"
+ value2 = "value2"
+ }
+ }
+}
+--------------------------------------------------
+
+In the above example, the source closure itself gets transformed into an
+XContent (defaults to JSON). In order to change how the source closure
+is serialized, a global (static) setting can be set on the `GClient` by
+changing the `indexContentType` field.
+
+Note also that the `source` can be set using the typical Java based
+APIs, the `Closure` option is a Groovy extension.