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 Details

    • Document

      public Document()
  • Method Details

    • getInputDoc

      public abstract @Nullable String getInputDoc()
    • getBulkDirective

      public abstract @Nullable String getBulkDirective()
    • getHasError

      public abstract Boolean getHasError()
    • getResponseItemJson

      public abstract @Nullable String getResponseItemJson()
    • getTimestamp

      public abstract @Nullable Instant getTimestamp()
    • create

      public static ElasticsearchIO.Document create()
    • withInputDoc

      public ElasticsearchIO.Document withInputDoc(String inputDoc)
      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 either ElasticsearchIO.Write or ElasticsearchIO.DocToBulk
      Parameters:
      inputDoc - Serialized json input document destined to end up in Elasticsearch.
      Returns:
      WriteSummary with inputDocument set.
    • withBulkDirective

      public ElasticsearchIO.Document withBulkDirective(String bulkDirective)
      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

      public ElasticsearchIO.Document withResponseItemJson(String responseItemJson)
      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

      public ElasticsearchIO.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. Note that if using ElasticsearchIO.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

      public ElasticsearchIO.Document 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.
      Parameters:
      timestamp - The timestamp with which the WriteSummary will be output.
      Returns:
      WriteSummary with timestamp set.