"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.23/docs/groovy-api/index_.asciidoc" (29 Dec 2021, 917 Bytes) of package /linux/www/elasticsearch-6.8.23-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming AsciiDoc format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

Index API

The index API is very similar to the Java index API. The Groovy extension to it is the ability to provide the indexed source using a closure. For example:

def indexR = client.index {
    index "test"
    type "_doc"
    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.