diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 462986535..f561b9b68 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -1,16 +1,19 @@ [[configuration]] == Configuration -The `Client` constructor accepts a single object as it's argument, and the following keys can be used to configure that client instance. +The `Client` constructor accepts a single object as it's argument. In the <> section all of the available options/keys are listed. [source,js] ------ var elasticsearch = require('elasticsearch'); var client = new elasticsearch.Client({ - ... + ... config options ... }); ------ +WARNING: Due to the complex nature of the configuration, the config object you pass in will be modified and can only be used to create one `Client` instance. Sorry for the inconvenience. Related Github issue: https://github.com/elasticsearch/elasticsearch-js/issues/33 + +[[config-options]] === Config options [horizontal] `host or hosts`[[config-hosts]]:: diff --git a/src/lib/client.js b/src/lib/client.js index fb677e19a..ff7d612ea 100755 --- a/src/lib/client.js +++ b/src/lib/client.js @@ -32,6 +32,13 @@ var _ = require('./utils'); function Client(config) { config = config || {}; + if (config.__reused) { + throw new Error('Do not reuse objects to configure the elasticsearch Client class: ' + + 'https://github.com/elasticsearch/elasticsearch-js/issues/33'); + } else { + config.__reused = true; + } + function EsApiClient() { // our client will log minimally by default if (!config.hasOwnProperty('log')) {