About

Features

  • One-to-one mapping with REST API
  • Configurable, automatic discovery of cluster nodes
  • Persistent, Keep-Alive connections
  • Intelligent handling of node/connection failure
  • Load balancing (with plug-able selection strategy) across all available nodes.
  • Works great in node, as well as modern browsers (many thanks to https://github com/substack/node-browserify[browserify]!!).
  • Generalized, plug-able, and highly configurable architecture. You can change anything! See Extending

Install in Node

npm install --save elasticsearch

Browser Builds

We also provide builds of the elasticsearch.js client for use in the browser. These versions of the client are currently experimental. They will break from time to time and should probably not be used on public-facing websites. We test these builds using saucelabs in Chrome, Firefox, and Internet Explorer 9, 10, and 11.

Bower

If you use bower to manage your dependencies, then just run

bower install elasticsearch

Download

To download a build of elasticsearch.js which functions well within modern browsers, use the links below. These versions of the client are currently experimental. They will break from time to time and should probably not be used on public-facing websites (it’s a whopping 150kb of code).

Warning

The entire API is compatible with IE 10+, Chrome, Firefox, Safari, and Opera. The majority of the API will also work in IE 8 & 9, but those browsers limit cross domain requests to just GET and POST. IE versions before 8 do not support cross-domain requests nativly.

Angular Build (elasticsearch.angular.js)

  • Registers the elasticsearch object as a factory esFactory
  • Uses Angular’s $http service
  • Returns promises using Angular’s $q service to properly trigger digest cycles within Angular

Create a client instance and register it as a service. 

module.service('es', function (esFactory) {
  return esFactory({
    host: 'localhost:9200',
    // ...
  });
});

jQuery Build (elasticsearch.jquery.js)

  • Uses jQuery’s .ajax() functionality
  • Returns jQuery "promises"
  • Registers the module at jQuery.es

Create a client with the jQuery build. 

var client = new $.es.Client({
  hosts: 'localhost:9200'
});