From b073292b777caf58e2c77553568dd5cbcaa8b1a2 Mon Sep 17 00:00:00 2001 From: Andrew Oppenlander Date: Mon, 31 Aug 2015 17:36:59 -0400 Subject: [PATCH] Added section for extending a Connection. --- docs/extending_core_components.asciidoc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/extending_core_components.asciidoc b/docs/extending_core_components.asciidoc index 7fa3b51f3..b091f3c79 100644 --- a/docs/extending_core_components.asciidoc +++ b/docs/extending_core_components.asciidoc @@ -3,7 +3,29 @@ We decided to make this client low-level, and as such we probably have not implemented all the features you are looking for. For this reason, we made extending or even replacing the core components simple. === Connection -Coming Soon +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`: +[source,js] +--------------- +var elasticsearch = require('elasticsearch'); +var util = require('util'); +var HttpConnector = require('elasticsearch/src/lib/connectors/http'); + +function MyHttpConnector(host, config) { + HttpConnector.call(this, host, config); +} +util.inherits(MyHttpConnector, HttpConnector); +MyHttpConnector.prototype.makeReqParams = function(params) { + params = params || {}; + params.method = params.method || 'POST'; + returh HttpConnector.prototype.makeReqParams.call(this, params); +}; + +var client = new elasticsearch.Client({ + connectionClass: MyHttpConnector +}); +--------------- === ConnectionPool Coming Soon