@seedalpha/elastic-index

ElasticSearch index management library

Usage no npm install needed!

<script type="module">
  import seedalphaElasticIndex from 'https://cdn.skypack.dev/@seedalpha/elastic-index';
</script>

README

ElasticIndex

ElasticSearch index management library

Changelog

3.2.0:

  • explicit options
  • documentation

3.1.0:

  • handle noop cases, e.g. esIndex.index(doc._id, doc);

3.0.0:

  • move index type (name) to options
  • remove debug option
  • use visionmedia/debug

2.0.0:

  • get read of too specific env variables
  • use elastic search connection string instead of host/port pair

Prerequisites

$ npm set registry http://npm.sandbox.elasticseed.net
$ npm set always-auth true
$ npm login

Installation

$ npm install elastic-index --save

Usage

// index.js
var ElasticIndex = require('elastic-index');

var bookIndex = new ElasticIndex({
  type: 'books',
  index: 'development',
  url: 'https://username:password@host:port'
});

bookIndex.index('1', { name: 'War and Peace' }, function(error) {
  if (!error) console.log('Book indexed');
});

bookIndex.unindex('1', function(error) {
  if (!error) return console.log('Book removed from index);
});

// abstract
var index = new ElasticIndex(options);
  • type {String}, elasticsearch type
  • index {String}, elasticsearch index
  • url {String}, elasticsearch url, default 'http://localhost:9200'

Debug

$ DEBUG=elastic-index npm test

Development

$ git clone git@github.com:seedalpha/elastic-index.git
$ cd elastic-index
$ npm install
$ ES_URL=${ELASTIC_SEARCH_URL} npm test                # to run on mongohq elasticsearch instance (staging)
$ ES_URL=${ELASTIC_SEARCH_URL} NOCK_OFF=true npm test  # to mock requests and run locally

Author

Vladimir Popov vlad@seedalpha.net

License

©2014 Seedalpha