blob: b3a96334bcf9e5f330ceda2158e8f8e26ca01583 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
[[index_]]
== Index API
The index API is very similar to the
// {javaclient}/java-docs-index.html[]
Java index API. The Groovy
extension to it is the ability to provide the indexed source using a
closure. For example:
[source,groovy]
--------------------------------------------------
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.
|