Class ElasticsearchIO.Document
java.lang.Object
org.apache.beam.sdk.io.elasticsearch.ElasticsearchIO.Document
- All Implemented Interfaces:
Serializable
- Enclosing class:
ElasticsearchIO
@DefaultCoder(DocumentCoder.class)
public abstract static class ElasticsearchIO.Document
extends Object
implements Serializable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ElasticsearchIO.Document
create()
abstract Boolean
withBulkDirective
(String bulkDirective) Sets the bulk directive representation of an input document.withHasError
(boolean hasError) Used to set whether or not there was an error for a given document as indicated by the response from Elasticsearch.withInputDoc
(String inputDoc) Sets the input document i.e.withResponseItemJson
(String responseItemJson) Sets the element from Elasticsearch Bulk API response "items" pertaining to this WriteSummary.withTimestamp
(Instant timestamp) Sets the timestamp of the element in the PCollection, to be used in order to output WriteSummary to the same window from which the inputDoc originated.
-
Constructor Details
-
Document
public Document()
-
-
Method Details
-
getInputDoc
-
getBulkDirective
-
getHasError
-
getResponseItemJson
-
getTimestamp
-
create
-
withInputDoc
Sets the input document i.e. desired document that will end up in Elasticsearch for this WriteSummary object. The inputDoc will be a document that was part of the input PCollection to eitherElasticsearchIO.Write
orElasticsearchIO.DocToBulk
- Parameters:
inputDoc
- Serialized json input document destined to end up in Elasticsearch.- Returns:
- WriteSummary with inputDocument set.
-
withBulkDirective
Sets the bulk directive representation of an input document. This will be new-line separated JSON where each line is valid JSON. Typically the first line includes meta-data and instructions to Elasticsearch such as whether to overwrite a document, delete it, etc. and the second line (if present) will be the document itself. For more info please see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html- Parameters:
bulkDirective
- Serialized new-line delimited json bulk API information.- Returns:
- WriteSummary with bulkDirective set.
-
withResponseItemJson
Sets the element from Elasticsearch Bulk API response "items" pertaining to this WriteSummary.- Parameters:
responseItemJson
- The Elasticsearch Bulk API response.- Returns:
- WriteSummary with Elasticsearch Bulk API response set.
-
withHasError
Used to set whether or not there was an error for a given document as indicated by the response from Elasticsearch. Note that if usingElasticsearchIO.Write.withAllowableResponseErrors(java.util.Set<java.lang.String>)
errors which are allowed will have a false value for hasError for their respective WriteSummary.- Parameters:
hasError
- Whether or not Elasticsearch returned an error when persisting a bulk directive.- Returns:
- WriteSummary with hasError set.
-
withTimestamp
Sets the timestamp of the element in the PCollection, to be used in order to output WriteSummary to the same window from which the inputDoc originated.- Parameters:
timestamp
- The timestamp with which the WriteSummary will be output.- Returns:
- WriteSummary with timestamp set.
-