Skip to content

Directly use ES endpoint #1

Description

@olivierlambert

It's relatively easy to write the result directly in an ES database.

You need the elasticsearch package. Then:

  • import it
  • connect
  • delete the index (if already exists)
  • create the mapping
  • send the data
import elasticsearch from 'elasticsearch'

const client = new elasticsearch.Client({
  host: 'https://user:password@elastic.tld.com:443',
  apiVersion: 'master',
  maxSockets: 100,
  requestTimeout: 1800000
})

yield client.indices.create({ index: 'github-stats' })

yield client.indices.putMapping({
  index: 'github-stats',
  type: 'event',
  body: { ... }
})

...

client.index({
  index: 'github-stats',
  type: 'event',
  body: { ... }
}, function (error, response) {
   if (error) {
     console.log(error)
    }
  }
})

...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions