Skip to main content

Elasticsearch and OpenSearch connector plugin for onestep.

Project description

onestep-elasticsearch

onestep-elasticsearch provides one asynchronous bulk sink for the common Elasticsearch and OpenSearch HTTP API surface.

Install

pip install onestep-elasticsearch

Python

from onestep_elasticsearch import ElasticsearchConnector

search = ElasticsearchConnector(
    ["https://search-1:9200", "https://search-2:9200"],
    distribution="auto",
    username="ingest",
    password="secret",
    verify_certs=True,
    ca_certs="/etc/ssl/search-ca.pem",
    request_timeout_s=30.0,
)
sink = search.bulk_sink(
    index="events-v1", operation="index", id_field="event_id",
    chunk_size=500, max_chunk_bytes=5_000_000, refresh=False,
)

YAML

resources:
  search:
    type: elasticsearch
    hosts: ["${SEARCH_URL}"]
    distribution: auto
    username: "${SEARCH_USERNAME}"
    password: "${SEARCH_PASSWORD}"
    verify_certs: true
    ca_certs: "${SEARCH_CA_FILE:-/etc/ssl/certs/ca-certificates.crt}"
    request_timeout_s: 30
  events:
    type: elasticsearch_bulk_sink
    connector: search
    index: events-v1
    operation: index
    id_field: event_id
    chunk_size: 500
    max_chunk_bytes: 5000000
    refresh: false

Payloads and transport

send() accepts one mapping or one non-empty sequence of mappings. Each mapping is the complete document _source; id_field also supplies _id while remaining in _source. The sink chunks sequentially by action count and serialized NDJSON bytes, and rejects invalid or oversized payloads before submission.

The common boundary uses HTTP(S), GET /, and POST /_bulk. distribution is auto, elasticsearch, or opensearch. Configure exactly one authentication mode: Basic username/password, api_key, or bearer_token. Custom headers, verify_certs, ca_certs, client_cert, and client_key cover the supported TLS and proxy boundary. Clients are created lazily; an injected client remains caller owned, while a connector-owned client is closed by await connector.close().

Compatibility

The supported release matrix is Elasticsearch 8.x and 9.x plus OpenSearch 2.x and 3.x. Compatibility is defined by the shared HTTP bulk behavior, not a vendor Python client version. The environment-gated live suite uses ONESTEP_ELASTICSEARCH_URL or ONESTEP_OPENSEARCH_URL.

Delivery semantics

send() returns only after every bulk item in every chunk is acknowledged. onestep acknowledges the source after sink sends, so a crash between the bulk acknowledgement and source acknowledgement can duplicate output. Multi-sink fan-out is not transactional. Use operation: index with a stable id_field when replay must converge; auto-generated IDs and create are not replay-safe.

Bulk chunks are not transactional. Item failures retain a redacted typed cause with the item index, status, identifier, and normalized reason. A partial commit is reported as UNCERTAIN unless index with a stable id_field makes replay deterministic. create conflicts and malformed documents are permanent failures.

Request-level 502, 503, and 504 responses are ambiguous after the request body has been sent. The sink retries them internally only when operation: index and a present id_field make replay convergent. A request-level 429 is an explicit rejection and remains retryable without stable IDs.

Deferred features

Version 1 intentionally excludes Cloud ID, sniffing, SigV4, data streams, administration APIs, dynamic actions, update/delete, PIT, SQL, elasticsearch_search_after, and elasticsearch_scroll.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onestep_elasticsearch-0.1.2.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onestep_elasticsearch-0.1.2-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file onestep_elasticsearch-0.1.2.tar.gz.

File metadata

  • Download URL: onestep_elasticsearch-0.1.2.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for onestep_elasticsearch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f04924e384a25d9dd4c5237e0ef2d02c7199b338558338ce1c0b4a8987b7cfe7
MD5 c3d8a9fa6893e5624a9df2c7f2b4be98
BLAKE2b-256 952986f8676659d8dc54e436d22eb152816dc2b3b49c500bc1bbba1ded1af947

See more details on using hashes here.

File details

Details for the file onestep_elasticsearch-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for onestep_elasticsearch-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 73cb7872ad06db1c68ca0a880ad61b32ad45d9a64a7b9011f944dd6e7c54b29f
MD5 7d3ecd804e48f1726a663243686be329
BLAKE2b-256 c73624c80b39b043601ae5d123e64c0e1c2977891bab3fa2282f37611d87c557

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page