Merge branch 'master' into 2.2

This commit is contained in:
Spencer Alger
2014-05-22 09:10:33 -07:00
18 changed files with 9846 additions and 96 deletions

View File

@ -2,7 +2,8 @@ language: node_js
node_js: "0.10" node_js: "0.10"
secure: "UFAGQ6m/VnEahbj9vttY9YoA5h5rEBE6K7AvEEbWnt+VKppV+w3hu3HZxgKr8C9PWhCzqlGvsLh+kCqykZhISU1fBCK/Ttp3nSpMvvF5tI2u51Rj1qZ/7NUGRU0qVI9KFt0rJeXMJwq3fivb1H6aojfPD1gsIte7NHNjUfd0iUg=" secure: "UFAGQ6m/VnEahbj9vttY9YoA5h5rEBE6K7AvEEbWnt+VKppV+w3hu3HZxgKr8C9PWhCzqlGvsLh+kCqykZhISU1fBCK/Ttp3nSpMvvF5tI2u51Rj1qZ/7NUGRU0qVI9KFt0rJeXMJwq3fivb1H6aojfPD1gsIte7NHNjUfd0iUg="
env: env:
- ES_BRANCH=1.1 ES_RELEASE=1.1.1 COVERAGE=1 - ES_BRANCH=1.2 ES_RELEASE=1.2.0 COVERAGE=1
- ES_BRANCH=1.1 ES_RELEASE=1.1.2 NODE_UNIT=0
- ES_BRANCH=1.0 ES_RELEASE=1.0.3 NODE_UNIT=0 - ES_BRANCH=1.0 ES_RELEASE=1.0.3 NODE_UNIT=0
- ES_BRANCH=0.90 ES_RELEASE=0.90.13 NODE_UNIT=0 - ES_BRANCH=0.90 ES_RELEASE=0.90.13 NODE_UNIT=0
- NODE_UNIT=0 NODE_INTEGRATION=0 BROWSER_UNIT=1 - NODE_UNIT=0 NODE_INTEGRATION=0 BROWSER_UNIT=1

View File

@ -1,5 +1,10 @@
# elasticsearch-js changelog # elasticsearch-js changelog
## 2.2 (Mar 27 2014)
- The default API version is now `'1.2'`
- Node clinet now supports master, 1.x, 1.2, 1.1, 1.0, and 0.90
- Browser client now supports versions 1.0, 1.1, and 1.2
## 2.1 (Mar 27 2014) ## 2.1 (Mar 27 2014)
- The default API version is now `'1.1'` - The default API version is now `'1.1'`
- Errors generated in the browser will now have stack traces - Errors generated in the browser will now have stack traces

View File

@ -49,7 +49,7 @@ bower install elasticsearch
[Jenkins](http://build.elasticsearch.com/job/es-js_nightly/) [Jenkins](http://build.elasticsearch.com/job/es-js_nightly/)
Elasticsearch.js provides support for, and is regularly tested against, Elasticsearch releases **0.90.5 and greater**. We also test against the latest changes in the 0.90 and master branches of 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.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/configuration.html#_config_options) Elasticsearch.js provides support for, and is regularly tested against, Elasticsearch releases **0.90.5 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.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/configuration.html#_config_options)
## Examples ## Examples

View File

@ -1,10 +1,11 @@
[[api-reference]] [[api-reference]]
== 1.1 API == 1.2 API
NOTE: This is currently the default API, but in upcomming versions that will change. We recommend setting the `apiVersion` config param when you instantiate your client to make sure that the API does not change unexpectedly. NOTE: This is currently the default API, but in upcomming versions that will change. We recommend setting the `apiVersion` config param when you instantiate your client to make sure that the API does not change unexpectedly.
[[js-api-method-index]] [[js-api-method-index]]
* <<api-abortbenchmark,abortBenchmark>>
* <<api-bulk,bulk>> * <<api-bulk,bulk>>
* <<api-clearscroll,clearScroll>> * <<api-clearscroll,clearScroll>>
* <<api-count,count>> * <<api-count,count>>
@ -18,6 +19,7 @@ NOTE: This is currently the default API, but in upcomming versions that will cha
* <<api-getsource,getSource>> * <<api-getsource,getSource>>
* <<api-index,index>> * <<api-index,index>>
* <<api-info,info>> * <<api-info,info>>
* <<api-listbenchmarks,listBenchmarks>>
* <<api-mget,mget>> * <<api-mget,mget>>
* <<api-mlt,mlt>> * <<api-mlt,mlt>>
* <<api-mpercolate,mpercolate>> * <<api-mpercolate,mpercolate>>
@ -35,6 +37,7 @@ NOTE: This is currently the default API, but in upcomming versions that will cha
* <<api-cat-aliases,cat.aliases>> * <<api-cat-aliases,cat.aliases>>
* <<api-cat-allocation,cat.allocation>> * <<api-cat-allocation,cat.allocation>>
* <<api-cat-count,cat.count>> * <<api-cat-count,cat.count>>
* <<api-cat-fielddata,cat.fielddata>>
* <<api-cat-health,cat.health>> * <<api-cat-health,cat.health>>
* <<api-cat-help,cat.help>> * <<api-cat-help,cat.help>>
* <<api-cat-indices,cat.indices>> * <<api-cat-indices,cat.indices>>
@ -83,7 +86,6 @@ NOTE: This is currently the default API, but in upcomming versions that will cha
* <<api-indices-recovery,indices.recovery>> * <<api-indices-recovery,indices.recovery>>
* <<api-indices-refresh,indices.refresh>> * <<api-indices-refresh,indices.refresh>>
* <<api-indices-segments,indices.segments>> * <<api-indices-segments,indices.segments>>
* <<api-indices-snapshotindex,indices.snapshotIndex>>
* <<api-indices-stats,indices.stats>> * <<api-indices-stats,indices.stats>>
* <<api-indices-status,indices.status>> * <<api-indices-status,indices.status>>
* <<api-indices-updatealiases,indices.updateAliases>> * <<api-indices-updatealiases,indices.updateAliases>>
@ -101,6 +103,29 @@ NOTE: This is currently the default API, but in upcomming versions that will cha
* <<api-snapshot-restore,snapshot.restore>> * <<api-snapshot-restore,snapshot.restore>>
* <<api-snapshot-status,snapshot.status>> * <<api-snapshot-status,snapshot.status>>
[[api-abortbenchmark]]
=== `abortBenchmark`
[source,js]
--------
client.abortBenchmark([params, [callback]])
--------
// no description
The default method is `POST` and the usual <<api-conventions,params and return values>> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method.
// no examples
==== Params
[horizontal]
`name`::
`String` -- A benchmark name
link:#[back to top]
[[api-bulk]] [[api-bulk]]
=== `bulk` === `bulk`
@ -918,6 +943,31 @@ The default method is `GET` and the usual <<api-conventions,params and return va
[[api-listbenchmarks]]
=== `listBenchmarks`
[source,js]
--------
client.listBenchmarks([params, [callback]])
--------
// no description
The default method is `GET` and the usual <<api-conventions,params and return values>> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method.
// no examples
==== Params
[horizontal]
`index`::
`String, String[], Boolean` -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
`type`::
`String` -- The name of the document type
link:#[back to top]
[[api-mget]] [[api-mget]]
=== `mget` === `mget`
@ -1580,7 +1630,7 @@ client.searchTemplate([params, [callback]])
// no description // no description
The default method is `POST` and the usual <<api-conventions,params and return values>> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-search.html[the elasticsearch docs] for more about this method. The default method is `POST` and the usual <<api-conventions,params and return values>> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for more about this method.
// no examples // no examples
@ -1588,6 +1638,32 @@ The default method is `POST` and the usual <<api-conventions,params and return v
==== Params ==== Params
[horizontal] [horizontal]
`ignoreUnavailable`::
`Boolean` -- Whether specified concrete indices should be ignored when unavailable (missing or closed)
`allowNoIndices`::
`Boolean` -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
`[expandWildcards=open]`::
`String` -- Whether to expand wildcard expression to concrete indices that are open, closed or both.
Options:::
* `"open"`
* `"closed"`
`preference`::
`String` -- Specify the node or shard the operation should be performed on (default: random)
`routing`::
`String, String[], Boolean` -- A comma-separated list of specific routing values
`scroll`::
`Duration` -- Specify how long a consistent view of the index should be maintained for scrolled search
`searchType`::
`String` -- Search operation type
Options:::
* `"query_then_fetch"`
* `"query_and_fetch"`
* `"dfs_query_then_fetch"`
* `"dfs_query_and_fetch"`
* `"count"`
* `"scan"`
`index`:: `index`::
`String, String[], Boolean` -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices `String, String[], Boolean` -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
`type`:: `type`::
@ -1840,8 +1916,6 @@ Options:::
`String` -- Specific version type `String` -- Specific version type
Options::: Options:::
* `"internal"` * `"internal"`
* `"external"`
* `"external_gte"`
* `"force"` * `"force"`
`id`:: `id`::
@ -1960,6 +2034,47 @@ The default method is `GET` and the usual <<api-conventions,params and return va
link:#[back to top] link:#[back to top]
[[api-cat-fielddata]]
=== `cat.fielddata`
[source,js]
--------
client.cat.fielddata([params, [callback]])
--------
// no description
The default method is `GET` and the usual <<api-conventions,params and return values>> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-fielddata.html[the elasticsearch docs] for more about this method.
// no examples
==== Params
[horizontal]
`bytes`::
`String` -- The unit in which to display byte values
Options:::
* `"b"`
* `"k"`
* `"m"`
* `"g"`
`local`::
`Boolean` -- Return local information, do not retrieve the state from master node (default: false)
`masterTimeout`::
`Date, Number` -- Explicit operation timeout for connection to master node
`h`::
`String, String[], Boolean` -- Comma-separated list of column names to display
`help`::
`Boolean` -- Return help information
`v`::
`Boolean` -- Verbose mode. Display column headers
`fields`::
`String, String[], Boolean` -- A comma-separated list of fields to return the fielddata size
link:#[back to top]
[[api-cat-health]] [[api-cat-health]]
=== `cat.health` === `cat.health`
@ -2465,8 +2580,6 @@ The default method is `GET` and the usual <<api-conventions,params and return va
`Boolean` -- Return local information, do not retrieve the state from master node (default: false) `Boolean` -- Return local information, do not retrieve the state from master node (default: false)
`masterTimeout`:: `masterTimeout`::
`Date, Number` -- Specify timeout for connection to master `Date, Number` -- Specify timeout for connection to master
`indexTemplates`::
`String, String[], Boolean` -- A comma separated list to return specific index templates when returning metadata
`flatSettings`:: `flatSettings`::
`Boolean` -- Return settings in flat format (default: false) `Boolean` -- Return settings in flat format (default: false)
`index`:: `index`::
@ -3580,39 +3693,6 @@ Options:::
link:#[back to top] link:#[back to top]
[[api-indices-snapshotindex]]
=== `indices.snapshotIndex`
[source,js]
--------
client.indices.snapshotIndex([params, [callback]])
--------
Initiate a snapshot through the gateway of one or more indices.
The default method is `POST` and the usual <<api-conventions,params and return values>> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/indices-gateway-snapshot.html[the elasticsearch docs] for more about this method.
// no examples
==== Params
[horizontal]
`ignoreUnavailable`::
`Boolean` -- Whether specified concrete indices should be ignored when unavailable (missing or closed)
`allowNoIndices`::
`Boolean` -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
`[expandWildcards=open]`::
`String` -- Whether to expand wildcard expression to concrete indices that are open, closed or both.
Options:::
* `"open"`
* `"closed"`
`index`::
`String, String[], Boolean` -- A comma-separated list of index names; use `_all` or empty string for all indices
link:#[back to top]
[[api-indices-stats]] [[api-indices-stats]]
=== `indices.stats` === `indices.stats`

File diff suppressed because it is too large Load Diff

View File

@ -51,12 +51,20 @@ 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. 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 ::: `"1.1"` Default ::: `"1.2"`
Options ::: Options in node :::
* `"1.2"`
* `"1.1"` * `"1.1"`
* `"1.0"` * `"1.0"`
* `"0.90"` * `"0.90"`
* `"master"` (unstable)
* `"1.x"` (unstable)
Options in the browser :::
* `"1.2"`
* `"1.1"`
* `"1.0"`

View File

@ -18,6 +18,8 @@ include::development.asciidoc[]
include::api_methods.asciidoc[] include::api_methods.asciidoc[]
include::api_methods_1_1.asciidoc[]
include::api_methods_1_0.asciidoc[] include::api_methods_1_0.asciidoc[]
include::api_methods_0_90.asciidoc[] include::api_methods_0_90.asciidoc[]

View File

@ -55,8 +55,11 @@ utils.branches.forEach(function (branch) {
case '0.90': case '0.90':
args.push('-f'); args.push('-f');
break; break;
case 'master': case '1.0':
case '1.x': case '1.1':
// no special treatment
break;
default:
args.push('-Des.node.bench=true', '-Des.script.disable_dynamic=false'); args.push('-Des.node.bench=true', '-Des.script.disable_dynamic=false');
break; break;
} }

View File

@ -20,6 +20,7 @@
"pattern": "specified in test/unit/coverage.js" "pattern": "specified in test/unit/coverage.js"
}, },
"supported_es_branches": [ "supported_es_branches": [
"1.2",
"1.1", "1.1",
"1.0", "1.0",
"0.90" "0.90"
@ -28,7 +29,7 @@
"master", "master",
"1.x" "1.x"
], ],
"default_api_branch": "1.1" "default_api_branch": "1.2"
}, },
"devDependencies": { "devDependencies": {
"mocha": "^1.18.2", "mocha": "^1.18.2",

View File

@ -71,12 +71,11 @@ function manage_es {
local ES_URL="https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_RELEASE}.zip" local ES_URL="https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_RELEASE}.zip"
local ES_DIR="${SNAPSHOTS}/${ES_VERSION}" local ES_DIR="${SNAPSHOTS}/${ES_VERSION}"
else else
if [[ $ES_BRANCH == "master" ]]; then # TODO: TRASH THIS
local JDK='JDK7' if [[ $ES_BRANCH == "master" ]]; then local JDK='JDK7'
elif [[ $ES_BRANCH == "1.x" ]]; then elif [[ $ES_BRANCH == "1.x" ]]; then local JDK='JDK7'
local JDK='JDK7' elif [[ $ES_BRANCH == "1.2" ]]; then local JDK='JDK7'
else else local JDK='JDK6'
local JDK='JDK6'
fi fi
local ES_VERSION="${ES_BRANCH}_nightly" local ES_VERSION="${ES_BRANCH}_nightly"
@ -135,19 +134,23 @@ function manage_es {
return 1 return 1
fi fi
local ES_OPTS="-p $PIDFILE -Des.http.port=9400 -Des.network.host=localhost -Des.discovery.zen.ping.multicast.enabled=false -Des.discovery.zen.ping_timeout=1" local ES_OPTS="-p $PIDFILE -D es.http.port=9400 -D es.network.host=localhost -D es.cluster.name=elasticsearch_js_test_runners -D es.node.name=elasticsearch_js_test_runner -D es.gateway.type=none -D es.index.store.type=memory -D es.discovery.zen.ping.multicast.enabled=false -D es.discovery.zen.ping_timeout=1 -D es.logger.level=ERROR"
if [ -n "$ES_NODE_NAME" ]; then if [ -n "$ES_NODE_NAME" ]; then
ES_OPTS="$ES_OPTS -Des.node.name=$ES_NODE_NAME" ES_OPTS="$ES_OPTS -Des.node.name=$ES_NODE_NAME"
fi fi
if [ "$ES_BRANCH" = "0.90" ]; then if [[ $ES_BRANCH != "0.90" ]]; then
echo "Starting Elasticsearch $ES_VERSION" # explicitly run as deamon
call $ES_BIN $ES_OPTS ES_OPTS="-d $ES_OPTS"
else
echo "Starting Elasticsearch $ES_VERSION as a deamon"
call $ES_BIN -d $ES_OPTS
fi fi
if [[ $ES_BRANCH != "1.0" && $ES_BRANCH != "1.1" ]]; then
# enable scripting and benchmarks
ES_OPTS="$ES_OPTS -D es.node.bench=true -D es.script.disable_dynamic=false"
fi
call $ES_BIN $ES_OPTS
;; ;;
stop) stop)
if [ -e $PIDFILE ]; then if [ -e $PIDFILE ]; then

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
source $HOME/.nvm/nvm.sh
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $HERE/_utils.sh
case $1 in
setup)
group "installing node 0.10"
nvm install 0.10
npm --quiet install
;;
run)
group "test node 0.10"
nvm use 0.10
echo "rebuilding npm deps"
npm rebuild &> /dev/null
call ES_BRANCH=master COVERAGE=1 ./scripts/ci.sh
call ES_BRANCH=1.0 NODE_UNIT=0 ./scripts/ci.sh
call ES_BRANCH=0.90 NODE_UNIT=0 ./scripts/ci.sh
group "test browsers"
call NODE_UNIT=0 NODE_INTEGRATION=0 BROWSER_UNIT=1 ./scripts/ci.sh
;;
esac

View File

@ -34,6 +34,10 @@ var optimist = require('optimist')
help: { help: {
describe: 'This help message', describe: 'This help message',
type: 'boolean' type: 'boolean'
},
reset: {
describe: 'Clear all logstash-* indices before genrating logs',
type: 'boolean'
} }
}); });
@ -270,6 +274,15 @@ queue.drain = function () {
}; };
async.series([ async.series([
function (done) {
if (argv.reset) {
client.indices.delete({
index: 'logstash-*'
}, done);
} else {
done();
}
},
function (done) { function (done) {
client.cluster.putSettings({ client.cluster.putSettings({
body: { body: {

View File

@ -8,13 +8,17 @@ var bowerDir = root + '/src/bower_es_js';
// get both the bower and node package files // get both the bower and node package files
var bowerJson = require(bowerDir + '/bower.json'); var bowerJson = require(bowerDir + '/bower.json');
var bowerPackageJson = require(bowerDir + '/package.json');
var esjsJson = require(root + '/package.json'); var esjsJson = require(root + '/package.json');
// update the version to match the node version // update the version to match the node version
bowerJson.version = esjsJson.version; bowerJson.version = esjsJson.version;
bowerPackageJson.version = esjsJson.version;
// write the new bower.json file // write the new bower.json file
fs.writeFileSync(bowerDir + '/bower.json', JSON.stringify(bowerJson, null, ' ')); fs.writeFileSync(bowerDir + '/bower.json', JSON.stringify(bowerJson, null, ' '));
// write the new package.json file
fs.writeFileSync(bowerDir + '/package.json', JSON.stringify(bowerPackageJson, null, ' '));
function make(cmd, args) { function make(cmd, args) {
return _.bind(spawn, null, cmd, args, { return _.bind(spawn, null, cmd, args, {

5518
src/lib/apis/1_2.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
module.exports = { module.exports = {
'1.2': require('./1_2'),
'1.1': require('./1_1'), '1.1': require('./1_1'),
'1.0': require('./1_0'), '1.0': require('./1_0')
'0.90': require('./0_90')
}; };

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
'master': require('./master'), 'master': require('./master'),
'1.x': require('./1_x'), '1.x': require('./1_x'),
'1.2': require('./1_2'),
'1.1': require('./1_1'), '1.1': require('./1_1'),
'1.0': require('./1_0'), '1.0': require('./1_0'),
'0.90': require('./0_90') '0.90': require('./0_90')

View File

@ -63,7 +63,7 @@ function Client(config) {
delete this._namespaces; delete this._namespaces;
} }
EsApiClient.prototype = _.funcEnum(config, 'apiVersion', Client.apis, '1.1'); EsApiClient.prototype = _.funcEnum(config, 'apiVersion', Client.apis, '1.2');
if (!config.sniffEndpoint && EsApiClient.prototype === Client.apis['0.90']) { if (!config.sniffEndpoint && EsApiClient.prototype === Client.apis['0.90']) {
config.sniffEndpoint = '/_cluster/nodes'; config.sniffEndpoint = '/_cluster/nodes';
} }

View File

@ -23,17 +23,17 @@ describe('Client instances creation', function () {
var def = require('../../../package.json').config.default_api_branch; var def = require('../../../package.json').config.default_api_branch;
it('inherits the ' + def + ' API by default', function () { it('inherits the ' + def + ' API by default', function () {
expect(client.bulk).to.eql(apis[def].bulk); expect(client.bulk).to.be(apis[def].bulk);
expect(client.nodes.stats).to.eql(apis[def].nodes.prototype.stats); expect(client.nodes.stats).to.be(apis[def].nodes.prototype.stats);
}); });
it('inherits the 0.90 API when specified', function () { it('inherits the 1.0 API when specified', function () {
client.close(); client.close();
client = es.Client({ client = es.Client({
apiVersion: '0.90' apiVersion: '1.0'
}); });
expect(client.bulk).to.eql(apis['0.90'].bulk); expect(client.bulk).to.be(apis['1.0'].bulk);
expect(client.cluster.nodeStats).to.eql(apis['0.90'].cluster.prototype.nodeStats); expect(client.cluster.nodeStats).to.be(apis['1.0'].cluster.prototype.nodeStats);
}); });
it('closing the client causes it\'s transport to be closed', function () { it('closing the client causes it\'s transport to be closed', function () {