Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @shelf/elasticsearch-local with all npm packages installed. Try it out:

var elasticsearchLocal = require("@shelf/elasticsearch-local")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@shelf/elasticsearch-local v1.0.0

Run 6+ version of ElasticSearch locally

elasticsearch-local CircleCI npm (scoped)

Run any version of ElasticSearch locally

Usage

0. Install

$ yarn add @shelf/elasticsearch-local --dev

1. Start Elasticsearch

import {start} from '@shelf/elasticsearch-local';

await start({
  esVersion: '7.3.0',
  port: 9000, // optional
  clusterName: 'test', // optional
  nodeName: 'test', // optional
  indexes: [
    {
      name: 'your-index',
      // create index with options - https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#indices-create-api-request-body
      body: {
        settings: {
          number_of_shards: '1',
          number_of_replicas: '1'
        },
        aliases: {
          'some-acc-id': {}
        },
        mappings: {
          "properties": {
            "field1" : {"type" : "text"}
        }
      }
    }
  ] // optional
});

2. Stop Elasticsearch

import {stop} from '@shelf/elasticsearch-local';

await stop();

Publish

$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master

License

MIT © Shelf

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free