From b4cf5d7b1b5bd8722d627a89c51e90b506a48335 Mon Sep 17 00:00:00 2001 From: Marcos Sanz Date: Fri, 11 Jul 2014 12:38:11 +0200 Subject: [PATCH] Update client.js Add open and close index --- lib/client.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) 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