Skip to content

reshufflehq/reshuffle-elasticsearch-connector

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

reshuffle-elasticsearch-connector

Code | npm | Code sample

npm install reshuffle-elasticsearch-connector

This connector uses Elasticsearch Node JS Client package.

Reshuffle Elasticsearch Connector

This package contains a Reshuffle connector for connecting to Elasticsearch.

The following example adds a new entry to an existing index:

const { Reshuffle } = require('reshuffle')
const { ElasticsearchConnector } = require('reshuffle-elasticsearch-connector')

const elasticsearchOptions = {
  cloud: {
    id:
      '<name>:<id>',
  },
  auth: {
    username: '<username>',
    password: '<password>',
  },
}

const app = new Reshuffle()
const connector = new ElasticsearchConnector(app, elasticsearchOptions)

app.start()

connector.sdk().index({
  index: 'game-of-thrones',
  body: {
    character: 'Daenerys Targaryen',
    quote: 'I am the blood of the dragon.'
  }
})

Table of Contents

Setup Cloud elasticsearch

Configuration Options

Connector Events

N/A

Connector Actions

SDK - Retrieve a Node JS Elasticsearch client

Examples using the SDK

Setup Cloud Elasticsearch

Setup Elastic cloud:

  1. Go to https://cloud.elastic.co/home
  2. Click Create deployment
  3. Provide a name and create
  4. Copy the username/password
  5. Click on your deployment in the deployment list
  6. copy the cloud ID which is :
  7. See Configuration Options below for how to connect to this Elasticsearch cloud instance.

Configuration Options

The Elasticsearch connector takes the same options as the Node JS Elasticsearch client. See Node JS Elasticsearch Client options

As an example, for connecting to elasticsearch cloud, provide options as below:

const connector = new ElasticsearchConnector(app, {
  cloud: {
    id:
      '<deployment-name>:<key>', // Cloud ID (see Setup Cloud Elasticsearch above for obtaining this id)
  },
  auth: {
    username: '<username>',
    password: '<password>',
  },
})

Connector actions

All actions are provided via the sdk. // See full list of actions in Node JS Elasticsearch Client API reference

SDK

Return a Node Elasticsearch Client

const sdk = await connector.sdk()
Examples using the SDK
  • Search entries
const entries = await connector.sdk().search({
  index: 'my-index',
  from: 20,
  size: 10,
  body: { foo: 'bar' }
}, {
  ignore: [404],
  maxRetries: 3
})
  • Add entry
await connector.sdk().index({
  index: 'game-of-thrones',
  body: {
    character: 'Ned Stark',
    quote: 'Winter is coming.'
  }
})

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published