Summary of Changes:

- moved es install/start/stop logic into a seperate script
  - `grunt test` now runs the integration tests once for each version of ES we support
  - grunt can now install and run elasticearch (using grunt-run, pure js solution coming later)
  - included seperate es.sh script specifically for starting or stopping elasticsearch
  - url aliases, api, yaml_suite/index.js, and yaml_tests.json, are all now duplicated for 0_90 support
  - the client now accepts an apiVersion argument (undocumented) which defaults to 'master' but can be '0.90'
  - The yaml test runner will now check the name of the ES instance it is connecting to, preventing accidental wiping of ES
This commit is contained in:
Spencer Alger
2014-01-14 23:10:12 -07:00
parent 37ce4e440c
commit 18e134d0a6
30 changed files with 23318 additions and 560 deletions

View File

@ -1545,8 +1545,8 @@ api.indices.prototype['delete'] = ca({
* @param {Object} params - An object with parameters used to carry out this action
* @param {Date, Number} params.timeout - Explicit timestamp for the document
* @param {Date, Number} params.masterTimeout - Specify timeout for connection to master
* @param {String} params.index - The name of the index with an alias
* @param {String} params.name - The name of the alias to be deleted
* @param {String, String[], Boolean} params.index - A comma-separated list of index names (supports wildcards); use `_all` for all indices
* @param {String, String[], Boolean} params.name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices.
*/
api.indices.prototype.deleteAlias = ca({
params: {
@ -1558,30 +1558,18 @@ api.indices.prototype.deleteAlias = ca({
name: 'master_timeout'
}
},
urls: [
{
fmt: '/<%=index%>/_alias/<%=name%>',
req: {
index: {
type: 'string'
},
name: {
type: 'string'
}
url: {
fmt: '/<%=index%>/_alias/<%=name%>',
req: {
index: {
type: 'list'
},
name: {
type: 'list'
}
},
{
fmt: '/<%=index%>/_aliases/<%=name%>',
req: {
index: {
type: 'string'
},
name: {
type: 'string'
}
}
}
],
sortOrder: -2
},
method: 'DELETE'
});
@ -1590,8 +1578,8 @@ api.indices.prototype.deleteAlias = ca({
*
* @param {Object} params - An object with parameters used to carry out this action
* @param {Date, Number} params.masterTimeout - Specify timeout for connection to master
* @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` for all indices
* @param {String} params.type - The name of the document type to delete
* @param {String, String[], Boolean} params.index - A comma-separated list of index names (supports wildcards); use `_all` for all indices
* @param {String, String[], Boolean} params.type - A comma-separated list of document types to delete (supports wildcards); use `_all` to delete all document types in the specified indices.
*/
api.indices.prototype.deleteMapping = ca({
params: {
@ -1600,52 +1588,18 @@ api.indices.prototype.deleteMapping = ca({
name: 'master_timeout'
}
},
urls: [
{
fmt: '/<%=index%>/<%=type%>',
req: {
index: {
type: 'list'
},
type: {
type: 'string'
}
url: {
fmt: '/<%=index%>/<%=type%>/_mapping',
req: {
index: {
type: 'list'
},
type: {
type: 'list'
}
},
{
fmt: '/<%=index%>/_mapping/<%=type%>',
req: {
index: {
type: 'list'
},
type: {
type: 'string'
}
}
},
{
fmt: '/<%=index%>/<%=type%>/_mappings',
req: {
index: {
type: 'list'
},
type: {
type: 'string'
}
}
},
{
fmt: '/<%=index%>/_mappings/<%=type%>',
req: {
index: {
type: 'list'
},
type: {
type: 'string'
}
}
}
],
sortOrder: -2
},
method: 'DELETE'
});
@ -1684,15 +1638,17 @@ api.indices.prototype.deleteTemplate = ca({
*
* @param {Object} params - An object with parameters used to carry out this action
* @param {Date, Number} params.masterTimeout - Specify timeout for connection to master
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to register warmer for; use `_all` or empty string to perform the operation on all indices
* @param {String} params.name - The name of the warmer (supports wildcards); leave empty to delete all warmers
* @param {String, String[], Boolean} params.type - A comma-separated list of document types to register warmer for; use `_all` or empty string to perform the operation on all types
* @param {String, String[], Boolean} params.name - A comma-separated list of warmer names to delete (supports wildcards); use `_all` to delete all warmers in the specified indices. You must specify a name either in the uri or in the parameters.
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to delete warmers from (supports wildcards); use `_all` to perform the operation on all indices.
*/
api.indices.prototype.deleteWarmer = ca({
params: {
masterTimeout: {
type: 'time',
name: 'master_timeout'
},
name: {
type: 'list'
}
},
url: {
@ -1702,7 +1658,7 @@ api.indices.prototype.deleteWarmer = ca({
type: 'list'
},
name: {
type: 'string'
type: 'list'
}
},
sortOrder: -2
@ -2493,7 +2449,7 @@ api.indices.prototype.optimize = ca({
* @param {Object} params - An object with parameters used to carry out this action
* @param {Date, Number} params.timeout - Explicit timestamp for the document
* @param {Date, Number} params.masterTimeout - Specify timeout for connection to master
* @param {String} params.index - The name of the index with an alias
* @param {String, String[], Boolean} params.index - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` or omit to perform the operation on all indices.
* @param {String} params.name - The name of the alias to be created or updated
*/
api.indices.prototype.putAlias = ca({
@ -2511,18 +2467,7 @@ api.indices.prototype.putAlias = ca({
fmt: '/<%=index%>/_alias/<%=name%>',
req: {
index: {
type: 'string'
},
name: {
type: 'string'
}
}
},
{
fmt: '/<%=index%>/_aliases/<%=name%>',
req: {
index: {
type: 'string'
type: 'list'
},
name: {
type: 'string'
@ -2536,14 +2481,6 @@ api.indices.prototype.putAlias = ca({
type: 'string'
}
}
},
{
fmt: '/_aliases/<%=name%>',
req: {
name: {
type: 'string'
}
}
}
],
method: 'PUT'
@ -2559,7 +2496,7 @@ api.indices.prototype.putAlias = ca({
* @param {Boolean} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {Boolean} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` to perform the operation on all indices
* @param {String, String[], Boolean} params.index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices.
* @param {String} params.type - The name of the document type
*/
api.indices.prototype.putMapping = ca({
@ -2594,17 +2531,6 @@ api.indices.prototype.putMapping = ca({
}
},
urls: [
{
fmt: '/<%=index%>/<%=type%>/_mapping',
req: {
index: {
type: 'list'
},
type: {
type: 'string'
}
}
},
{
fmt: '/<%=index%>/_mapping/<%=type%>',
req: {
@ -2616,28 +2542,6 @@ api.indices.prototype.putMapping = ca({
}
}
},
{
fmt: '/<%=index%>/<%=type%>/_mappings',
req: {
index: {
type: 'list'
},
type: {
type: 'string'
}
}
},
{
fmt: '/<%=index%>/_mappings/<%=type%>',
req: {
index: {
type: 'list'
},
type: {
type: 'string'
}
}
},
{
fmt: '/_mapping/<%=type%>',
req: {
@ -2645,14 +2549,6 @@ api.indices.prototype.putMapping = ca({
type: 'string'
}
}
},
{
fmt: '/_mappings/<%=type%>',
req: {
type: {
type: 'string'
}
}
}
],
method: 'PUT'
@ -2760,7 +2656,7 @@ api.indices.prototype.putTemplate = ca({
* @param {Boolean} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) in the search request to warm
* @param {Boolean} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices in the search request to warm. (This includes `_all` string or when no indices have been specified)
* @param {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both, in the search request to warm.
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to register the warmer for; use `_all` or empty string to perform the operation on all indices
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to register the warmer for; use `_all` or omit to perform the operation on all indices
* @param {String} params.name - The name of the warmer
* @param {String, String[], Boolean} params.type - A comma-separated list of document types to register the warmer for; leave empty to perform the operation on all types
*/
@ -2803,20 +2699,6 @@ api.indices.prototype.putWarmer = ca({
}
}
},
{
fmt: '/<%=index%>/<%=type%>/_warmers/<%=name%>',
req: {
index: {
type: 'list'
},
type: {
type: 'list'
},
name: {
type: 'string'
}
}
},
{
fmt: '/<%=index%>/_warmer/<%=name%>',
req: {
@ -2828,17 +2710,6 @@ api.indices.prototype.putWarmer = ca({
}
}
},
{
fmt: '/<%=index%>/_warmers/<%=name%>',
req: {
index: {
type: 'list'
},
name: {
type: 'string'
}
}
},
{
fmt: '/_warmer/<%=name%>',
req: {
@ -2846,14 +2717,6 @@ api.indices.prototype.putWarmer = ca({
type: 'string'
}
}
},
{
fmt: '/_warmers/<%=name%>',
req: {
name: {
type: 'string'
}
}
}
],
method: 'PUT'

3226
src/lib/api_0_90.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -26,50 +26,57 @@
module.exports = Client;
var api = require('./api.js');
var ca = require('./client_action');
var Transport = require('./transport');
var ca = require('./client_action');
var _ = require('./utils');
var defaultApi = 'master';
var apis = {
'0.90': require('./api_0_90'),
'master': require('./api')
};
function Client(config) {
if (!(this instanceof Client)) {
return new Client(config);
}
config = config || {};
// our client will log minimally by default
if (!config.hasOwnProperty('log')) {
config.log = 'warning';
function EsApiClient(config) {
// our client will log minimally by default
if (!config.hasOwnProperty('log')) {
config.log = 'warning';
}
if (!config.hosts && !config.host) {
config.host = 'http://localhost:9200';
}
this.ping = ca({
method: 'HEAD',
url: {
fmt: '/'
},
castExists: true,
requestTimeout: 100
});
this.close = function () {
this.transport.close();
};
this.transport = new Transport(config);
// instantiate the api's namespaces
for (var i = 0; i < this._namespaces.length; i++) {
this[this._namespaces[i]] = new this[this._namespaces[i]](this.transport);
}
delete this._namespaces;
}
if (!config.hosts && !config.host) {
config.host = 'http://localhost:9200';
var apiVersion = config.apiVersion || defaultApi;
if (apis.hasOwnProperty(apiVersion)) {
EsApiClient.prototype = apis[apiVersion];
} else {
throw new Error('Invalid apiVersion "' + apiVersion + '", expected one of ' + _.keys(apis).join(', '));
}
this.transport = new Transport(config);
// instantiate the api's namespaces
for (var i = 0; i < this._namespaces.length; i++) {
this[this._namespaces[i]] = new this[this._namespaces[i]](this.transport);
}
return new EsApiClient(config);
}
Client.prototype = api;
/**
* Ping some node to ensure that the cluster is available in some respect
*
* @param {Object} params - Currently just a placeholder, no params used at this time
* @param {Function} cb - callback
*/
Client.prototype.ping = ca({
method: 'HEAD',
url: {
fmt: '/'
},
castExists: true,
requestTimeout: 100
});
Client.prototype.close = function () {
this.transport.close();
};

View File

@ -100,7 +100,7 @@ function adjustWordCase(firstWordCap, otherWordsCap, sep) {
for (; i < string.length; i++) {
code = string.charCodeAt(i);
c = string.charAt(i);
lower = code >= 97 && code <= 122;
lower = (code >= 97 && code <= 122) || (code >= 48 && code <= 57);
upper = code >= 65 && code <= 90;
if (upper || !lower) {