@Experimental(value=SOURCE_SINK) public class ElasticsearchIO extends java.lang.Object
ElasticsearchIO.read() returns a bounded
PCollection<String> representing JSON documents.
To configure the read(), you have to provide a connection configuration
containing the HTTP address of the instances, an index name and a type. The following example
illustrates options for configuring the source:
pipeline.apply(ElasticsearchIO.read().withConnectionConfiguration(
ElasticsearchIO.ConnectionConfiguration.create("http://host:9200", "my-index", "my-type")
)
The connection configuration also accepts optional configuration: withUsername() and
withPassword().
You can also specify a query on the read() using withQuery().
To write documents to Elasticsearch, use
ElasticsearchIO.write(), which writes JSON documents from a
PCollection<String> (which can be bounded or unbounded).
To configure ElasticsearchIO.write(), similar to the read, you
have to provide a connection configuration. For instance:
pipeline
.apply(...)
.apply(ElasticsearchIO.write().withConnectionConfiguration(
ElasticsearchIO.ConnectionConfiguration.create("http://host:9200", "my-index", "my-type")
)
Optionally, you can provide withBatchSize() and withBatchSizeBytes()
to specify the size of the write batch in number of documents or in bytes.
| Modifier and Type | Class and Description |
|---|---|
static class |
ElasticsearchIO.BoundedElasticsearchSource
A
BoundedSource reading from Elasticsearch. |
static class |
ElasticsearchIO.ConnectionConfiguration
A POJO describing a connection configuration to Elasticsearch.
|
static class |
ElasticsearchIO.Read
A
PTransform reading data from Elasticsearch. |
static class |
ElasticsearchIO.Write
A
PTransform writing data to Elasticsearch. |
| Modifier and Type | Method and Description |
|---|---|
static ElasticsearchIO.Read |
read() |
static ElasticsearchIO.Write |
write() |
public static ElasticsearchIO.Read read()
public static ElasticsearchIO.Write write()