Elasticsearch · Arazzo Workflow

Elasticsearch Document Lifecycle

Version 1.0.0

Index a document by id, read it back, apply a partial update, and confirm the merged result.

1 workflow 1 source API 1 provider
View Spec View on GitHub AnalyticsDatabaseFull-Text SearchNoSQLSearchArazzoWorkflows

Provider

elasticsearch

Workflows

document-lifecycle
Index, read, partially update, and re-read a single document by id.
Writes a document at a caller-supplied id, verifies the persisted source, merges a partial document into it, and verifies the merged result and the resulting version number.
4 steps inputs: document, id, index, partialUpdate outputs: documentId, finalVersion, mergedSource
1
indexDocument
indexDocument
Index the document at the supplied id. Elasticsearch answers 201 when the document is new and 200 when it replaced an existing document at that id, so both are accepted.
2
readAfterIndex
getDocument
Read the document straight back to confirm exactly what was persisted before any update is attempted.
3
applyPartialUpdate
updateDocument
Merge the partial document into the stored source. Fields not named in the partial update are left untouched.
4
readAfterUpdate
getDocument
Read the document a second time to confirm the merge landed and to capture the version Elasticsearch incremented to.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: Elasticsearch Document Lifecycle
  summary: Index a document by id, read it back, apply a partial update, and confirm the merged result.
  description: >-
    The core create-read-update loop for a single Elasticsearch document. The
    workflow indexes a document at a known id, reads it back to confirm what was
    persisted, applies a partial update through the _update endpoint, and reads
    it a second time so the caller can see the merged source and the incremented
    version. Reading back after each write is what makes this flow useful as an
    integration test as well as a data path. Every step spells out its request
    inline so the flow can be read and executed without opening the underlying
    OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: elasticsearchApi
  url: ../openapi/elasticsearch-openapi.yml
  type: openapi
workflows:
- workflowId: document-lifecycle
  summary: Index, read, partially update, and re-read a single document by id.
  description: >-
    Writes a document at a caller-supplied id, verifies the persisted source,
    merges a partial document into it, and verifies the merged result and the
    resulting version number.
  inputs:
    type: object
    required:
    - index
    - id
    - document
    - partialUpdate
    properties:
      index:
        type: string
        description: The index to write the document into.
      id:
        type: string
        description: The caller-controlled document id.
      document:
        type: object
        description: The full document source to index.
      partialUpdate:
        type: object
        description: The partial document to merge into the existing source.
  steps:
  - stepId: indexDocument
    description: >-
      Index the document at the supplied id. Elasticsearch answers 201 when the
      document is new and 200 when it replaced an existing document at that id,
      so both are accepted.
    operationId: indexDocument
    parameters:
    - name: index
      in: path
      value: $inputs.index
    - name: id
      in: path
      value: $inputs.id
    requestBody:
      contentType: application/json
      payload: $inputs.document
    successCriteria:
    - condition: $statusCode == 200 || $statusCode == 201
    outputs:
      documentId: $response.body#/_id
      result: $response.body#/result
      version: $response.body#/_version
  - stepId: readAfterIndex
    description: >-
      Read the document straight back to confirm exactly what was persisted
      before any update is attempted.
    operationId: getDocument
    parameters:
    - name: index
      in: path
      value: $inputs.index
    - name: id
      in: path
      value: $inputs.id
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      found: $response.body#/found
      source: $response.body#/_source
      version: $response.body#/_version
  - stepId: applyPartialUpdate
    description: >-
      Merge the partial document into the stored source. Fields not named in the
      partial update are left untouched.
    operationId: updateDocument
    parameters:
    - name: index
      in: path
      value: $inputs.index
    - name: id
      in: path
      value: $inputs.id
    requestBody:
      contentType: application/json
      payload:
        doc: $inputs.partialUpdate
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      result: $response.body#/result
      version: $response.body#/_version
  - stepId: readAfterUpdate
    description: >-
      Read the document a second time to confirm the merge landed and to capture
      the version Elasticsearch incremented to.
    operationId: getDocument
    parameters:
    - name: index
      in: path
      value: $inputs.index
    - name: id
      in: path
      value: $inputs.id
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      mergedSource: $response.body#/_source
      finalVersion: $response.body#/_version
  outputs:
    documentId: $steps.indexDocument.outputs.documentId
    mergedSource: $steps.readAfterUpdate.outputs.mergedSource
    finalVersion: $steps.readAfterUpdate.outputs.finalVersion