Working code snippets where each step builds on the previous ones.
Step 1: Add some data into the app (uses elasticsearch.js)
// app and authentication configurationsconst HOST_URL = "";const APPNAME = "createnewtestapp01";const CREDENTIALS = "RIvfxo1u1:dee8ee52-8b75-4b5b-be4f-9df3c364f59f";// Add data into our ES "app index"var Appbase = ;var appbase =;appbaseindextype: "product"id: "1"body:name: "A green door"price: 125tags: "home" "green"stores: "Walmart" "Target";
Step 2: Read the data stream from a particular DB location
Returns continous updates on a JSON document from a particular
Note: Existing document value is returned via
_index: "app`248"_type: "product"_id: "1"_version: 4found: true_source:name: "A green door"price: 125tags: "home" "green"stores: "Walmart" "Target"
getStream() returns an object which has
reconnect properties. Check out the getStreamTest.js where we make an update to the document and see any further updates to it via the "data" callback.
Step 3: Apply queries on data streams
Get continuous results by searching across the database streams. A query can be written using the ElasticSearch Query DSL - which supports composing boolean, regex, geo, fuzzy, range queries. Let's stream the results of a simple
match_all query on the
took: 1timed_out: false_shards:total: 1successful: 1failed: 0hits:total: 4max_score: 1hits: Object Object Object Object
searchStream() also returns an object, which can be conveniently listened via the
onData callback. Check out the searchStreamTest.js where we make an update that matches the query and see the results in the event stream.
For a complete API reference, check out JS API Ref doc.
Returns a reference object on which streaming requests can be performed.
args - A set of key/value pairs that configures the ElasticSearch Index url: "https://scalr.api.appbase.io" app: App name (equivalent to an ElasticSearch Index) credentials: A
username:passwordcombination used for Basic Auth.
Optionally (and like in the quick example above),
url can contain the credentials field in the format: https://<credentials>@scalr.appbase.io.
Get continuous updates on a JSON document with a
id.Returns an object.
args - A set of key/value pairs that makes the document URL type: ElasticSearch Type, a string id: Valid Document ID
Get continuous updates on search queries (fuzzy, boolean, geolocation, range, full-text).Returns an object.
args - A set of key/value pairs that makes the document URL type: ElasticSearch Type, a string body: A JSON Query Body (Any query matching the ElasticSearch Query DSL)