diff --git a/lib/client.js b/lib/client.js index 0a16535..2d630c2 100644 --- a/lib/client.js +++ b/lib/client.js @@ -833,6 +833,58 @@ Client.prototype = { }); }, + /** + Close index. + + [ElasticSearch docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html) + + @method close + @param {String} [names] Index name to close. If + not specified, all indices will be closed. + @param {Function} [callback] Callback function. + @param {Error|null} callback.err Error, or `null` on success. + @param {Object} callback.res ElasticSearch response data. + **/ + close: function (name, callback) { + name = name || '_all'; + var url = '/' + name; + url += '/_close/' + this._request(url, { + method: 'POST' + }, function (err, res) { + if (err) { + return callback(err, null, res), undefined; + } + callback(null, res); + }); + }, + + /** + Open index. + + [ElasticSearch docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html) + + @method open + @param {String} [names] Index name to open. If + not specified, all indices will be opened. + @param {Function} [callback] Callback function. + @param {Error|null} callback.err Error, or `null` on success. + @param {Object} callback.res ElasticSearch response data. + **/ + open: function (name, callback) { + name = name || '_all'; + var url = '/' + name; + url += '/_open/' + this._request(url, { + method: 'POST' + }, function (err, res) { + if (err) { + return callback(err, null, res), undefined; + } + callback(null, res); + }); + }, + // TODO: percolate, delete by query, more like this /** Registers a percolator for the given index or modifies the existing percolator