Extending a connection provides the powerful ability to change requests as they go out to the ElasticSearch REST API.

For example, you can extend the HttpConnector to force the default HTTP method to be POST:

var elasticsearch = require('elasticsearch');
var util = require('util');
var HttpConnector = require('elasticsearch/src/lib/connectors/http');

function MyHttpConnector(host, config) {, host, config);
util.inherits(MyHttpConnector, HttpConnector);
MyHttpConnector.prototype.makeReqParams = function(params) {
  params = params || {};
  params.method = params.method || 'POST';
  return, params);

var client = new elasticsearch.Client({
  connectionClass: MyHttpConnector