Skip to main content

IBM Streams Elasticsearch integration

Project description

Overview

Provides functions to store tuple data as JSON documents in Elasticsearch indices. This package exposes the com.ibm.streamsx.elasticsearch toolkit as Python methods for services on IBM Cloud.

Sample

A simple hello world example of a Streams application writing string messages to an index:

from streamsx.topology.topology import *
from streamsx.topology.schema import CommonSchema
from streamsx.topology.context import submit
import streamsx.elasticsearch as es

topo = Topology('ElasticsearchHelloWorld')

s = topo.source(['Hello', 'World!']).as_string()
es.bulk_insert(s, 'test-index-cloud')

submit('STREAMING_ANALYTICS_SERVICE', topo)

A simple example of a Streams application writing JSON messages to an index, with dynamic index name (part of the stream):

from streamsx.topology.topology import *
from streamsx.topology.schema import CommonSchema, StreamSchema
from streamsx.topology.context import submit
import streamsx.elasticsearch as es

schema = StreamSchema('tuple<rstring indexName, rstring document>')
topo = Topology()
s = topo.source([('idx1','{"msg":"This is message number 1"}'), ('idx2','{"msg":"This is message number 2"}')])
s = s.map(lambda x : x, schema=schema)
es.bulk_insert_dynamic(s, index_name_attribute='indexName', message_attribute='document')

submit('STREAMING_ANALYTICS_SERVICE', topo)

Documentation

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

streamsx.elasticsearch-0.5.0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

streamsx.elasticsearch-0.5.0-py2.py3-none-any.whl (10.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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