Merge branch 'master' of github.com:elastic/elasticsearch-js into non-poluting-promise-lib

This commit is contained in:
spalger
2016-04-05 12:41:01 -07:00
38 changed files with 12987 additions and 335 deletions

View File

@ -1,19 +0,0 @@
language: node_js
node_js: "4.0"
cache:
directories:
- esvm
- node_modules
before_cache:
- rm -rf esvm/*/logs esvm/data_dir
sudo: false
secure: "UFAGQ6m/VnEahbj9vttY9YoA5h5rEBE6K7AvEEbWnt+VKppV+w3hu3HZxgKr8C9PWhCzqlGvsLh+kCqykZhISU1fBCK/Ttp3nSpMvvF5tI2u51Rj1qZ/7NUGRU0qVI9KFt0rJeXMJwq3fivb1H6aojfPD1gsIte7NHNjUfd0iUg="
env:
- ES_HOST=0.0.0.0 ES_RELEASE=1.7.1 RUN=NODE_INTEGRATION
- ES_HOST=0.0.0.0 ES_RELEASE=1.7.1 RUN=NODE_UNIT,CHECK_COVERAGE,SAUCE_LABS
script: node ./scripts/ci.js
email:
recipients:
- spencer.alger@elasticsearch.com
on_success: change
on_failure: always

View File

@ -2,7 +2,6 @@
The official low-level Elasticsearch client for Node.js and the browser.
[![Build Status](http://img.shields.io/travis/elastic/elasticsearch-js/master.svg?style=flat-square)](https://travis-ci.org/elastic/elasticsearch-js?branch=master)
[![Coverage Status](http://img.shields.io/coveralls/elastic/elasticsearch-js/master.svg?style=flat-square)](https://coveralls.io/r/elastic/elasticsearch-js?branch=master)
[![Dependencies up to date](http://img.shields.io/david/elastic/elasticsearch-js.svg?style=flat-square)](https://david-dm.org/elastic/elasticsearch-js)
@ -37,12 +36,12 @@ Check out the [Browser Builds](http://www.elastic.co/guide/en/elasticsearch/clie
## Questions?
You can probably find help in the #elasticsearch-js or #kibana rooms on [freenode](http://webchat.freenode.net/?channels=elasticsearch-js).
You can probably find help in [#kibana](https://kiwiirc.com/client/irc.freenode.net/?#kibana) on freenode.
## Supported Elasticsearch Versions
[![Supporting Elasticsearch Version 0.90 to 2.0](http://img.shields.io/badge/elasticsearch-0.90--2.0-green.svg?style=flat-square)](http://build-eu-00.elasticsearch.org/job/es-js_nightly/)
![Supporting Elasticsearch Version 0.90 to 5.0-alpha1](https://img.shields.io/badge/elasticsearch-0.90%20to%205.0--alpha1-green.svg?style=flat-square)
Elasticsearch.js provides support for, and is regularly tested against, Elasticsearch releases 0.90.12 and greater. We also test against the latest changes in several branches in the Elasticsearch repository. To tell the client which version of Elastisearch you are using, and therefore the API it should provide, set the `apiVersion` config param. [More info](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html#config-options)

File diff suppressed because it is too large Load Diff

View File

@ -912,13 +912,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1014,13 +1014,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1026,13 +1026,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1026,13 +1026,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1122,13 +1122,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1176,13 +1176,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1176,13 +1176,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1223,13 +1223,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1223,13 +1223,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]

View File

@ -1037,13 +1037,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]
@ -1999,8 +2000,6 @@ Options:::
* `"internal"`
* `"force"`
`detectNoop`::
`Boolean` -- Specifying as true will cause Elasticsearch to check if there are changes and, if there arent, turn the update request into a noop.
`id`::
`String` -- Document ID
`index`::

File diff suppressed because it is too large Load Diff

View File

@ -1037,13 +1037,14 @@ client.msearch({
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
---------
*Params*
[horizontal]
@ -1999,8 +2000,6 @@ Options:::
* `"internal"`
* `"force"`
`detectNoop`::
`Boolean` -- Specifying as true will cause Elasticsearch to check if there are changes and, if there arent, turn the update request into a noop.
`id`::
`String` -- Document ID
`index`::

View File

@ -51,9 +51,10 @@ Default in Node:::
+
WARNING: This default will track the latest version of Elasticsearch, and is only intended to be used during development. It is highly recommended that you set this parameter in all code that is headed to production.
Default ::: `'2.1'`
Default ::: `'2.3'`
Options in node :::
* `'2.3'`
* `'2.2'`
* `'2.1'`
* `'2.0'`
@ -70,11 +71,11 @@ Options in node :::
* `'master'` (unstable)
Options in the browser :::
* `'2.3'`
* `'2.2'`
* `'2.1'`
* `'2.0'`
* `'1.7'`
* `'1.6'`
* `'2.x'` (unstable)
* `'master'` (unstable)

View File

@ -16,6 +16,6 @@ This module provides a `scrollToEnd` function which allows for processing each b
elasticsearch-scrolltoend is available on https://www.npmjs.com/package/elasticsearch-scrolltoend[npm].
=== elasticsearch-deletebyquery
This module provides the `deleteByQuery` method which was removed from the core API in ES 2.0.0. For those with the [Delete-by-query](https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugins-delete-by-query.html) installed, this will bring back that feature to your Elasticsearch-js client.
This module provides the `deleteByQuery` method which was removed from the core API in ES 2.0.0. For those with the https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugins-delete-by-query.html[Delete-by-query] installed, this will bring back that feature to your Elasticsearch-js client.
elasticsearch-deletebyquery is available on https://www.npmjs.com/package/elasticsearch-deletebyquery[npm].

View File

@ -20,9 +20,11 @@ include::logging.asciidoc[]
include::development.asciidoc[]
include::api_methods.asciidoc[]
include::api_methods_2_2.asciidoc[]
include::api_methods.asciidoc[]
include::api_methods_2_1.asciidoc[]
include::api_methods_2_0.asciidoc[]

View File

@ -20,6 +20,12 @@ var versionedOpts = [
'cluster.name': 'elasticsearch_js_test_runners',
'http.port': port,
'network.host': host,
'discovery.zen.minimum_master_nodes': 1
}
},
{
version: '<3',
config: {
'discovery.zen.ping.multicast.enabled': false
}
},
@ -36,21 +42,32 @@ var versionedOpts = [
'script.disable_dynamic': false
}
},
{
version: '>=1.6 <5.0',
config: {
'node.bench': true
}
},
{
version: '>2.0 <5.0',
config: {
'node.testattr': 'test'
}
},
{
version: '>=5.0',
config: {
'node.attr.testattr': 'test'
}
},
{
version: '>=1.6',
config: {
'node.bench': true,
'script.inline': true,
'script.indexed': true,
'path.repo': process.env.ES_PATH_REPO || fromRoot('.es-snapshot-repos'),
'repositories.url.allowed_urls': 'http://snapshot.*'
}
},
{
version: '>2.0',
config: {
'node.testattr': 'test'
}
}
];

View File

@ -19,8 +19,9 @@
"blanket": {
"pattern": "specified in test/unit/coverage.js"
},
"default_api_branch": "2.1",
"default_api_branch": "2.3",
"supported_es_branches": [
"2.3",
"2.2",
"2.1",
"2.0",
@ -59,7 +60,7 @@
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-uglify": "^0.11.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-esvm": "^2.0.0",
"grunt-esvm": "^3.1.1",
"grunt-mocha-cov": "^0.4.0",
"grunt-open": "~0.2.2",
"grunt-prompt": "~0.1.2",

View File

@ -19,7 +19,7 @@ Version.fromBranch = function (branch) {
var m;
// master === the highest version number
if (branch === 'master') return new Version('3.0.0');
if (branch === 'master') return new Version('5.0.0');
// n.m -> n.m.0
if (m = branch.match(/^\d+\.\d+$/)) return new Version(branch + '.0');

View File

@ -62,7 +62,7 @@ var paths = {
return fromRoot('src/_elasticsearch_' + _.snakeCase(branch) + '.tar');
},
getSpecPathInRepo: function (branch) {
return /^(master|2\.)/.test(branch) ? 'rest-api-spec/src/main/resources/rest-api-spec' : 'rest-api-spec';
return /^v?(master|[2-9]\.)/.test(branch) ? 'rest-api-spec/src/main/resources/rest-api-spec' : 'rest-api-spec';
}
};

View File

@ -199,5 +199,13 @@ function (spec) {
});
}
},
{
version: '>=2.0.0',
aliases: {
'reindex.rethrottle': [
'/_update_by_query/{task_id}/_rethrottle'
]
}
}
];

View File

@ -1,5 +1,6 @@
#!/bin/bash
export JAVA_HOME="/usr/lib/jvm/jdk8"
lockpath="/var/lock/setup_nodejs"
# pass a file name to aquire a lock
@ -64,4 +65,4 @@ install_node "$NODE_V"
npm install
release_lock
ES_PATH_REPO="./.es-snapshot-repos/$EXECUTOR_NUMBER/" ES_PORT=$((9400 + EXECUTOR_NUMBER)) RUN=NODE_UNIT,NODE_INTEGRATION VERBOSE=true node ./scripts/ci.js
ES_PATH_REPO="./.es-snapshot-repos/$EXECUTOR_NUMBER/" ES_PORT=$((9400 + EXECUTOR_NUMBER)) RUN=NODE_UNIT,NODE_INTEGRATION VERBOSE=true node ./scripts/ci.js

View File

@ -6075,7 +6075,6 @@ api.termvectors = ca({
* @param {Duration} params.ttl - Expiration time for the document
* @param {Number} params.version - Explicit version number for concurrency control
* @param {String} params.versionType - Specific version type
* @param {Boolean} params.detectNoop - Specifying as true will cause Elasticsearch to check if there are changes and, if there arent, turn the update request into a noop.
* @param {String} params.id - Document ID
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
@ -6136,10 +6135,6 @@ api.update = ca({
'force'
],
name: 'version_type'
},
detectNoop: {
type: 'boolean',
name: 'detect_noop'
}
},
url: {

View File

@ -6220,7 +6220,6 @@ api.termvectors = ca({
* @param {Duration} params.ttl - Expiration time for the document
* @param {Number} params.version - Explicit version number for concurrency control
* @param {String} params.versionType - Specific version type
* @param {Boolean} params.detectNoop - Specifying as true will cause Elasticsearch to check if there are changes and, if there arent, turn the update request into a noop.
* @param {String} params.id - Document ID
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
@ -6281,10 +6280,6 @@ api.update = ca({
'force'
],
name: 'version_type'
},
detectNoop: {
type: 'boolean',
name: 'detect_noop'
}
},
url: {

View File

@ -6234,7 +6234,6 @@ api.termvectors = ca({
* @param {Duration} params.ttl - Expiration time for the document
* @param {Number} params.version - Explicit version number for concurrency control
* @param {String} params.versionType - Specific version type
* @param {Boolean} params.detectNoop - Specifying as true will cause Elasticsearch to check if there are changes and, if there arent, turn the update request into a noop.
* @param {String} params.id - Document ID
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
@ -6295,10 +6294,6 @@ api.update = ca({
'force'
],
name: 'version_type'
},
detectNoop: {
type: 'boolean',
name: 'detect_noop'
}
},
url: {

6723
src/lib/apis/2_3.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ var ca = require('../client_action').makeFactoryWithModifier(function (spec) {
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot', 'tasks'];
/**
* Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request
@ -2094,8 +2094,8 @@ api.indices = namespace();
* @param {Boolean} params.preferLocal - With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)
* @param {String, String[], Boolean} params.text - The text on which the analysis should be performed (when request body is not used)
* @param {String} params.tokenizer - The name of the tokenizer to use for the analysis
* @param {Boolean} params.detail - With `true`, outputs more advanced details. (default: false)
* @param {String, String[], Boolean} params.attributes - A comma-separated list of token attributes to output, this parameter works only with `detail=true`
* @param {Boolean} params.explain - With `true`, outputs more advanced details. (default: false)
* @param {String, String[], Boolean} params.attributes - A comma-separated list of token attributes to output, this parameter works only with `explain=true`
* @param {String} [params.format=detailed] - Format of the output
*/
api.indices.prototype.analyze = ca({
@ -2126,7 +2126,7 @@ api.indices.prototype.analyze = ca({
tokenizer: {
type: 'string'
},
detail: {
explain: {
type: 'boolean'
},
attributes: {
@ -5215,6 +5215,45 @@ api.putTemplate = ca({
method: 'PUT'
});
/**
* Perform a [reindex](https://www.elastic.co/guide/en/elasticsearch/plugins/master/plugins-reindex.html) request
*
* @param {Object} params - An object with parameters used to carry out this action
* @param {Boolean} params.refresh - Should the effected indexes be refreshed?
* @param {Date, Number} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable.
* @param {String} params.consistency - Explicit write consistency setting for the operation
* @param {Boolean} params.waitForCompletion - Should the request should block until the reindex is complete.
*/
api.reindex = ca({
params: {
refresh: {
type: 'boolean'
},
timeout: {
type: 'time',
'default': '1m'
},
consistency: {
type: 'enum',
options: [
'one',
'quorum',
'all'
]
},
waitForCompletion: {
type: 'boolean',
'default': false,
name: 'wait_for_completion'
}
},
url: {
fmt: '/_reindex'
},
needBody: true,
method: 'POST'
});
/**
* Perform a [renderSearchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html) request
*
@ -6096,6 +6135,104 @@ api.suggest = ca({
method: 'POST'
});
api.tasks = namespace();
/**
* Perform a [tasks.cancel](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks-cancel.html) request
*
* @param {Object} params - An object with parameters used to carry out this action
* @param {String, String[], Boolean} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* @param {String, String[], Boolean} params.actions - A comma-separated list of actions that should be cancelled. Leave empty to cancel all.
* @param {String} params.parentNode - Cancel tasks with specified parent node.
* @param {String} params.parentTask - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.
* @param {Number} params.taskId - Cancel the task with specified task id (node_id:task_number)
*/
api.tasks.prototype.cancel = ca({
params: {
nodeId: {
type: 'list',
name: 'node_id'
},
actions: {
type: 'list'
},
parentNode: {
type: 'string',
name: 'parent_node'
},
parentTask: {
type: 'string',
name: 'parent_task'
}
},
urls: [
{
fmt: '/_tasks/<%=taskId%>/_cancel',
req: {
taskId: {
type: 'number'
}
}
},
{
fmt: '/_tasks/_cancel'
}
],
method: 'POST'
});
/**
* Perform a [tasks.list](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks-list.html) request
*
* @param {Object} params - An object with parameters used to carry out this action
* @param {String, String[], Boolean} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* @param {String, String[], Boolean} params.actions - A comma-separated list of actions that should be returned. Leave empty to return all.
* @param {Boolean} params.detailed - Return detailed task information (default: false)
* @param {String} params.parentNode - Return tasks with specified parent node.
* @param {String} params.parentTask - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
* @param {Boolean} params.waitForCompletion - Wait for the matching tasks to complete (default: false)
* @param {String} params.taskId - Return the task with specified id (node_id:task_number)
*/
api.tasks.prototype.list = ca({
params: {
nodeId: {
type: 'list',
name: 'node_id'
},
actions: {
type: 'list'
},
detailed: {
type: 'boolean'
},
parentNode: {
type: 'string',
name: 'parent_node'
},
parentTask: {
type: 'string',
name: 'parent_task'
},
waitForCompletion: {
type: 'boolean',
name: 'wait_for_completion'
}
},
urls: [
{
fmt: '/_tasks/<%=taskId%>',
req: {
taskId: {
type: 'string'
}
}
},
{
fmt: '/_tasks'
}
]
});
/**
* Perform a [termvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html) request
*
@ -6234,7 +6371,6 @@ api.termvectors = ca({
* @param {Duration} params.ttl - Expiration time for the document
* @param {Number} params.version - Explicit version number for concurrency control
* @param {String} params.versionType - Specific version type
* @param {Boolean} params.detectNoop - Specifying as true will cause Elasticsearch to check if there are changes and, if there arent, turn the update request into a noop.
* @param {String} params.id - Document ID
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
@ -6295,10 +6431,6 @@ api.update = ca({
'force'
],
name: 'version_type'
},
detectNoop: {
type: 'boolean',
name: 'detect_noop'
}
},
url: {
@ -6318,6 +6450,255 @@ api.update = ca({
method: 'POST'
});
/**
* Perform a [updateByQuery](https://www.elastic.co/guide/en/elasticsearch/plugins/master/plugins-reindex.html) request
*
* @param {Object} params - An object with parameters used to carry out this action
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.explain - Specify whether to return detailed information about score computation as part of a hit
* @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return as part of a hit
* @param {String, String[], Boolean} params.fielddataFields - A comma-separated list of fields to return as the field data representation of a field for each hit
* @param {Number} params.from - Starting offset (default: 0)
* @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.conflicts=abort] - What to do when the reindex hits version conflicts?
* @param {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random)
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String, String[], Boolean} params.routing - A comma-separated list of specific routing values
* @param {Duration} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search
* @param {String} params.searchType - Search operation type
* @param {Date, Number} params.searchTimeout - Explicit timeout for each search request. Defaults to no timeout.
* @param {Number} params.size - Number of hits to return (default: 10)
* @param {String, String[], Boolean} params.sort - A comma-separated list of <field>:<direction> pairs
* @param {String, String[], Boolean} params._source - True or false to return the _source field or not, or a list of fields to return
* @param {String, String[], Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field
* @param {String, String[], Boolean} params._sourceInclude - A list of fields to extract and return from the _source field
* @param {Number} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* @param {String, String[], Boolean} params.stats - Specific 'tag' of the request for logging and statistical purposes
* @param {String} params.suggestField - Specify which field to use for suggestions
* @param {String} [params.suggestMode=missing] - Specify suggest mode
* @param {Number} params.suggestSize - How many suggestions to return in response
* @param {Text} params.suggestText - The source text for which the suggestions should be returned
* @param {Date, Number} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable.
* @param {Boolean} params.trackScores - Whether to calculate and return scores even if they are not used for sorting
* @param {Boolean} params.version - Specify whether to return document version as part of a hit
* @param {Boolean} params.versionType - Should the document increment the version number (internal) on hit or not (reindex)
* @param {Boolean} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting
* @param {Boolean} params.refresh - Should the effected indexes be refreshed?
* @param {String} params.consistency - Explicit write consistency setting for the operation
* @param {Integer} params.scrollSize - Size on the scroll request powering the update_by_query
* @param {Boolean} params.waitForCompletion - Should the request should block until the reindex is complete.
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* @param {String, String[], Boolean} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types
*/
api.updateByQuery = ca({
params: {
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
explain: {
type: 'boolean'
},
fields: {
type: 'list'
},
fielddataFields: {
type: 'list',
name: 'fielddata_fields'
},
from: {
type: 'number'
},
ignoreUnavailable: {
type: 'boolean',
name: 'ignore_unavailable'
},
allowNoIndices: {
type: 'boolean',
name: 'allow_no_indices'
},
conflicts: {
type: 'enum',
'default': 'abort',
options: [
'abort',
'proceed'
]
},
expandWildcards: {
type: 'enum',
'default': 'open',
options: [
'open',
'closed',
'none',
'all'
],
name: 'expand_wildcards'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
},
preference: {
type: 'string'
},
q: {
type: 'string'
},
routing: {
type: 'list'
},
scroll: {
type: 'duration'
},
searchType: {
type: 'enum',
options: [
'query_then_fetch',
'dfs_query_then_fetch'
],
name: 'search_type'
},
searchTimeout: {
type: 'time',
name: 'search_timeout'
},
size: {
type: 'number'
},
sort: {
type: 'list'
},
_source: {
type: 'list'
},
_sourceExclude: {
type: 'list',
name: '_source_exclude'
},
_sourceInclude: {
type: 'list',
name: '_source_include'
},
terminateAfter: {
type: 'number',
name: 'terminate_after'
},
stats: {
type: 'list'
},
suggestField: {
type: 'string',
name: 'suggest_field'
},
suggestMode: {
type: 'enum',
'default': 'missing',
options: [
'missing',
'popular',
'always'
],
name: 'suggest_mode'
},
suggestSize: {
type: 'number',
name: 'suggest_size'
},
suggestText: {
type: 'text',
name: 'suggest_text'
},
timeout: {
type: 'time',
'default': '1m'
},
trackScores: {
type: 'boolean',
name: 'track_scores'
},
version: {
type: 'boolean'
},
versionType: {
type: 'boolean',
name: 'version_type'
},
requestCache: {
type: 'boolean',
name: 'request_cache'
},
refresh: {
type: 'boolean'
},
consistency: {
type: 'enum',
options: [
'one',
'quorum',
'all'
]
},
scrollSize: {
type: 'integer',
name: 'scroll_size'
},
waitForCompletion: {
type: 'boolean',
'default': false,
name: 'wait_for_completion'
}
},
urls: [
{
fmt: '/<%=index%>/<%=type%>/_update_by_query',
req: {
index: {
type: 'list'
},
type: {
type: 'list'
}
}
},
{
fmt: '/<%=index%>/_update_by_query',
req: {
index: {
type: 'list'
}
}
}
],
method: 'POST'
});
/**
* Perform a [create](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request
*

View File

@ -1,10 +1,10 @@
module.exports = {
'_default': require('./2_3'),
'2.3': require('./2_3'),
'2.2': require('./2_2'),
'_default': require('./2_1'),
'2.1': require('./2_1'),
'2.0': require('./2_0'),
'1.7': require('./1_7'),
'1.6': require('./1_6'),
'2.x': require('./2_x'),
'master': require('./master')
};

View File

@ -1,6 +1,7 @@
module.exports = {
'_default': require('./2_3'),
'2.3': require('./2_3'),
'2.2': require('./2_2'),
'_default': require('./2_1'),
'2.1': require('./2_1'),
'2.0': require('./2_0'),
'1.7': require('./1_7'),

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,7 @@ Log.loggers = require('./loggers');
Log.prototype.close = function () {
this.emit('closing');
if (this.listenerCount()) {
console.error('Something is still listening for log events, but the logger is closing.');
console.error('Something is still listening for log events, but the logger is closing.'); // eslint-disable-line no-console
this.clearAllListeners();
}
};

4
test/.eslintrc Normal file
View File

@ -0,0 +1,4 @@
---
extends: ../.eslintrc
env:
mocha: true

View File

@ -2,25 +2,22 @@ var BROWSER = process.env.browser;
var VERBOSE = process.env.VERBOSE;
var JENKINS = !!process.env.JENKINS_HOME;
var es;
if (BROWSER) {
var es = window.elasticsearch;
es = window.elasticsearch;
} else {
var es = require('../../../src/elasticsearch');
es = require('../../../src/elasticsearch');
}
var _ = require('../../../src/lib/utils');
var path = require('path');
var fs = require('fs');
var async = require('async');
var fromRoot = _.bindKey(path, 'join', require('find-root')(__dirname));
var Bluebird = require('bluebird');
// current client
var client = null;
// when set to a boolean, hold the test of a ping
var externalExists;
module.exports = {
create: function create(apiVersion, port, host, cb) {
// create a client and ping the server for up to 15 seconds

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
/**
* Class to wrap a single document from a yaml test file
*
@ -112,7 +114,7 @@ function YamlDoc(doc, file) {
self._last_requests_response = null;
// setup the actions, creating a bound and testable method for each
self._actions = _.map(self.flattenTestActions(doc[self.description]), function (action, i) {
self._actions = _.map(self.flattenTestActions(doc[self.description]), function (action) {
// get the method that will do the action
var method = self['do_' + action.name];
@ -156,6 +158,19 @@ function YamlDoc(doc, file) {
return action;
});
self.getActionsRunners = function () {
return self._actions.map(function (action) {
return function (cb) {
clientManager.get().transport.log.debug(
'===========================\n' +
action.name +
'\n==========================='
);
return action.testable(cb);
};
});
};
}
YamlDoc.compareRangeToVersion = function (range, version) {
@ -373,11 +388,26 @@ YamlDoc.prototype = {
delete args.catch;
var inputParams = {};
// resolve the headers for a request
if (args.headers) {
inputParams.headers = args.headers;
delete args.headers;
}
var otherKeys = _.keys(args);
var action = otherKeys.shift();
if (otherKeys.length) {
return done(new TypeError('Unexpected top-level args to "do": ' + otherKeys.join(', ')));
}
var client = clientManager.get();
var action = _.keys(args).pop();
var clientActionName = _.map(action.split('.'), _.camelCase).join('.');
var clientAction = this.get(clientActionName, client);
var params = _.transform(args[action], function (params, val, name) {
_.assign(inputParams, args[action]);
var params = _.transform(inputParams, function (params, val, name) {
var camelName = _.camelCase(name);
// search through the params and url peices to find this param name
@ -418,7 +448,7 @@ YamlDoc.prototype = {
}
var timeoutId;
var cb = _.bind(function (error, body, status) {
var cb = _.bind(function (error, body) {
this._last_requests_response = body;
clearTimeout(timeoutId);

View File

@ -1,3 +1,5 @@
/* eslint-env mocha */
/* eslint-disable no-console */
/**
* Class representing a YAML file
* @type {[type]}
@ -20,16 +22,21 @@ function YamlFile(filename, docs) {
doc = new YamlDoc(doc, file);
if (doc.description === 'setup') {
beforeEach(/* doc */function (done) {
async.series(_.pluck(doc._actions, 'testable'), done);
async.series(doc.getActionsRunners(), done);
});
} else {
it(doc.description, function (done) {
async.series(_.pluck(doc._actions, 'testable'), done);
async.series(doc.getActionsRunners(), done);
});
}
});
afterEach(/* doc */function () {
clientManager.get().transport.log.debug(
'===========================\n' +
'Cleanup\n' +
'==========================='
);
return clientManager.get().clearEs();
});
});

View File

@ -1,59 +1,85 @@
describe('Client instances creation', function () {
var path = require('path');
var stream = require('stream');
var util = require('util');
var es = require('../../../src/elasticsearch');
var apis = require('../../../src/lib/apis');
var expect = require('expect.js');
var stub = require('../../utils/auto_release_stub').make();
var client;
beforeEach(function () {
client = new es.Client();
});
afterEach(function () {
client.close();
});
it('throws an error linking to the es module when you try to instanciate the exports', function () {
var Es = es;
expect(function () {
var c = new Es();
}).to.throwError(/previous "elasticsearch" module/);
});
var pkg = require('../../../package.json');
var def = pkg.config.default_api_branch;
var prev = pkg.config.supported_es_branches[pkg.config.supported_es_branches.indexOf(def) + 1];
it('inherits the ' + def + ' API by default', function () {
expect(client.bulk).to.be(apis[def].bulk);
expect(client.nodes.stats).to.be(apis[def].nodes.prototype.stats);
});
it('inherits the ' + prev + ' API when specified', function () {
client.close();
client = es.Client({
apiVersion: prev
describe('', function () {
beforeEach(function () {
client = new es.Client();
});
afterEach(function () {
client.close();
});
it('throws an error linking to the es module when you try to instanciate the exports', function () {
var Es = es;
expect(function () {
var c = new Es();
return c
}).to.throwError(/previous "elasticsearch" module/);
});
var pkg = require('../../../package.json');
var def = pkg.config.default_api_branch;
var prev = pkg.config.supported_es_branches[pkg.config.supported_es_branches.indexOf(def) + 1];
it('inherits the ' + def + ' API by default', function () {
expect(client.bulk).to.be(apis[def].bulk);
expect(client.nodes.stats).to.be(apis[def].nodes.prototype.stats);
});
it('inherits the ' + prev + ' API when specified', function () {
client.close();
client = es.Client({
apiVersion: prev
});
expect(client.bulk).to.be(apis[prev].bulk);
expect(client.cluster.nodeStats).to.be(apis[prev].cluster.prototype.nodeStats);
});
it('closing the client causes it\'s transport to be closed', function () {
var called = false;
client.transport.close = function () {
called = true;
};
client.close();
expect(called).to.be(true);
});
it('creates a warning level logger by default', function () {
expect(client.transport.log.listenerCount('error')).to.eql(1);
expect(client.transport.log.listenerCount('warning')).to.eql(1);
expect(client.transport.log.listenerCount('info')).to.eql(0);
expect(client.transport.log.listenerCount('debug')).to.eql(0);
expect(client.transport.log.listenerCount('trace')).to.eql(0);
});
expect(client.bulk).to.be(apis[prev].bulk);
expect(client.cluster.nodeStats).to.be(apis[prev].cluster.prototype.nodeStats);
});
it('closing the client causes it\'s transport to be closed', function () {
var called = false;
client.transport.close = function () {
called = true;
};
client.close();
expect(called).to.be(true);
});
describe('config', function () {
it('accepts a stream type logger', function (done) {
function NullStream() {
stream.Writable.call(this);
}
util.inherits(NullStream, stream.Writable);
it('creates a warning level logger by default', function () {
expect(client.transport.log.listenerCount('error')).to.eql(1);
expect(client.transport.log.listenerCount('warning')).to.eql(1);
expect(client.transport.log.listenerCount('info')).to.eql(0);
expect(client.transport.log.listenerCount('debug')).to.eql(0);
expect(client.transport.log.listenerCount('trace')).to.eql(0);
NullStream.prototype._write = function(/* chunk, encoding, next */) {
done();
};
var client = new es.Client({
log: [
{ type: 'stream', stream: new NullStream() }
]
});
client.transport.log.error(new Error());
});
});
describe('#ping', function () {