From 2b5f6cd80dd6e47890412da59f98dfd7a5637ba9 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 2 Dec 2013 18:30:30 -0700 Subject: [PATCH] lots of changes, should have committed earlier --- .gitignore | 1 + README.md | 12 +- docs/api.md | 988 ------------- docs/configuration.md | 117 -- docs/customize_logging.md | 3 - docs/errors.md | 39 - docs/examples.md | 52 - docs/replacing_core_components.md | 11 - log | 1218 +++++++++++++++++ package.json | 6 +- scripts/export_client.js | 2 +- scripts/export_docs.js | 96 ++ scripts/generate/js_api/actions.js | 39 +- scripts/generate/js_api/index.js | 14 +- .../generate/js_api/templates/api_docs.tmpl | 62 - .../js_api/templates/api_method_list.tmpl | 32 + .../js_api/templates/api_methods.tmpl | 40 + scripts/generate/js_api/templates/index.js | 9 +- scripts/generate/logs/index.js | 45 +- scripts/generate/logs/samples/countries.js | 250 ---- scripts/generate/logs/samples/countries.json | 250 ++++ .../generate/logs/samples/weighted_list.js | 5 +- scripts/generate/yaml_tests/index.js | 2 +- scripts/rest_spec_updated.js | 84 +- .../run_browser_integration_suite/index.js | 100 +- .../run_browser_integration_suite/server.js | 36 +- scripts/run_tests.js | 19 +- src/elasticsearch.js | 5 +- src/lib/api.js | 264 ++-- src/lib/client.js | 2 +- src/lib/client_action.js | 18 +- src/lib/connection.js | 22 +- src/lib/connectors/angular.js | 2 +- src/lib/connectors/http.js | 52 +- src/lib/connectors/jquery.js | 16 +- src/lib/connectors/xhr.js | 8 +- src/lib/host.js | 37 +- src/lib/logger.js | 4 +- src/lib/nodes_to_host.js | 20 + src/lib/transport.js | 6 +- test/fixtures/large_response.json | 0 test/unit/test_client_action.js | 23 +- test/unit/test_host.js | 58 +- test/unit/test_http_connection.js | 58 - test/unit/test_http_connector.js | 306 +++++ 45 files changed, 2498 insertions(+), 1935 deletions(-) delete mode 100644 docs/api.md delete mode 100644 docs/configuration.md delete mode 100644 docs/customize_logging.md delete mode 100644 docs/errors.md delete mode 100644 docs/examples.md delete mode 100644 docs/replacing_core_components.md create mode 100644 log create mode 100644 scripts/export_docs.js delete mode 100644 scripts/generate/js_api/templates/api_docs.tmpl create mode 100644 scripts/generate/js_api/templates/api_method_list.tmpl create mode 100644 scripts/generate/js_api/templates/api_methods.tmpl delete mode 100644 scripts/generate/logs/samples/countries.js create mode 100644 scripts/generate/logs/samples/countries.json create mode 100644 src/lib/nodes_to_host.js create mode 100644 test/fixtures/large_response.json delete mode 100644 test/unit/test_http_connection.js create mode 100644 test/unit/test_http_connector.js diff --git a/.gitignore b/.gitignore index f24b757af..ad77748a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ dist +docs npm-debug.log node_modules scripts/scratch* diff --git a/README.md b/README.md index 2880c3f4b..7a1434308 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,9 @@ bower install elasticsearch-jquery ``` ## Docs - - [Configuration](docs/configuration.md) - - [Examples](docs/examples.md) - - [API](docs/api.md) - - [Replacing Core Components](docs/replacing_core_components.md) - - [Errors](docs/errors.md) - - [Customize Logging](docs/customize_logging.md) + - [Quick Start](http://spenceralger.github.io/elasticsearch-js/index.html#quick-start) + - [API](http://spenceralger.github.io/elasticsearch-js/api.html) + - [Configuration](http://spenceralger.github.io/elasticsearch-js/index.html#configuration) + - [Extending Core Components](http://spenceralger.github.io/elasticsearch-js/index.html#extending) + - [Logging](http://spenceralger.github.io/elasticsearch-js/index.html#logging) + - [Contributing](http://spenceralger.github.io/elasticsearch-js/index.html#contributing) diff --git a/docs/api.md b/docs/api.md deleted file mode 100644 index 6e00a85d9..000000000 --- a/docs/api.md +++ /dev/null @@ -1,988 +0,0 @@ -# API - -## Table Of Contents - - - [Generic Params](#generic-params) - - [Methods](#methods) - - [bulk](#bulk) - - [clearScroll](#clearscroll) - - [cluster.getSettings](#clustergetsettings) - - [cluster.health](#clusterhealth) - - [cluster.nodeHotThreads](#clusternodehotthreads) - - [cluster.nodeInfo](#clusternodeinfo) - - [cluster.nodeShutdown](#clusternodeshutdown) - - [cluster.nodeStats](#clusternodestats) - - [cluster.putSettings](#clusterputsettings) - - [cluster.reroute](#clusterreroute) - - [cluster.state](#clusterstate) - - [count](#count) - - [create](#create) - - [delete](#delete) - - [deleteByQuery](#deletebyquery) - - [exists](#exists) - - [explain](#explain) - - [get](#get) - - [getSource](#getsource) - - [index](#index) - - [indices.analyze](#indicesanalyze) - - [indices.clearCache](#indicesclearcache) - - [indices.close](#indicesclose) - - [indices.create](#indicescreate) - - [indices.delete](#indicesdelete) - - [indices.deleteAlias](#indicesdeletealias) - - [indices.deleteMapping](#indicesdeletemapping) - - [indices.deleteTemplate](#indicesdeletetemplate) - - [indices.deleteWarmer](#indicesdeletewarmer) - - [indices.exists](#indicesexists) - - [indices.existsAlias](#indicesexistsalias) - - [indices.existsType](#indicesexiststype) - - [indices.flush](#indicesflush) - - [indices.getAlias](#indicesgetalias) - - [indices.getAliases](#indicesgetaliases) - - [indices.getFieldMapping](#indicesgetfieldmapping) - - [indices.getMapping](#indicesgetmapping) - - [indices.getSettings](#indicesgetsettings) - - [indices.getTemplate](#indicesgettemplate) - - [indices.getWarmer](#indicesgetwarmer) - - [indices.open](#indicesopen) - - [indices.optimize](#indicesoptimize) - - [indices.putAlias](#indicesputalias) - - [indices.putMapping](#indicesputmapping) - - [indices.putSettings](#indicesputsettings) - - [indices.putTemplate](#indicesputtemplate) - - [indices.putWarmer](#indicesputwarmer) - - [indices.refresh](#indicesrefresh) - - [indices.segments](#indicessegments) - - [indices.snapshotIndex](#indicessnapshotindex) - - [indices.stats](#indicesstats) - - [indices.status](#indicesstatus) - - [indices.updateAliases](#indicesupdatealiases) - - [indices.validateQuery](#indicesvalidatequery) - - [info](#info) - - [mget](#mget) - - [mlt](#mlt) - - [msearch](#msearch) - - [percolate](#percolate) - - [scroll](#scroll) - - [search](#search) - - [suggest](#suggest) - - [update](#update) - -## Generic Params - -Several parameters can be passed to any API method, and will control the way that those requests are carried out. These parameters are not listed in each method's param list. - -| Name | Type | Description | -| ---- | ---- | ----------- | -| `[timeout=10000]` | Number | The number of milliseconds this request has to complete. It defaults to the timeout specified at the client level, which defaults to 10 seconds. | -| `ignore` | Number or Number[] | Don't treat these HTTP status codes as "errors". Example use cases could be `ignore: 404` or `ignore: [404]` | - -## Methods - -### bulk() - -http://elasticsearch.org/guide/reference/api/bulk/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`consistency` | String | Explicit write consistency setting for the operation| -|`refresh` | Boolean | Refresh the index after performing the operation| -|`[replication=sync]` | String | Explicitely set the replication type| -|`type` | String | Default document type for items which don't provide one| -|`timeout` | Date or Number | Explicit operation timeout| -|`index` | String | Default index for items which don't provide one| - - -### clearScroll() - -http://www.elasticsearch.org/guide/reference/api/search/scroll/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`scrollId` | String or String[] or Boolean | A comma-separated list of scroll IDs to clear| - - -### cluster.getSettings() - -http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/ - --- none -- - - -### cluster.health() - -http://elasticsearch.org/guide/reference/api/admin-cluster-health/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[level=cluster]` | String | Specify the level of detail for returned information| -|`local` | Boolean | Return local information, do not retrieve the state from master node (default: false)| -|`masterTimeout` | Date or Number | Explicit operation timeout for connection to master node| -|`timeout` | Date or Number | Explicit operation timeout| -|`waitForActiveShards` | Number | Wait until the specified number of shards is active| -|`waitForNodes` | String | Wait until the specified number of nodes is available| -|`waitForRelocatingShards` | Number | Wait until the specified number of relocating shards is finished| -|`waitForStatus` | String | Wait until cluster is in a specific state| -|`index` | String | Limit the information returned to a specific index| - - -### cluster.nodeHotThreads() - -http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-hot-threads/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`interval` | Date or Number | The interval for the second sampling of threads| -|`snapshots` | Number | Number of samples of thread stacktrace (default: 10)| -|`threads` | Number | Specify the number of threads to provide information for (default: 3)| -|`type` | String | The type to sample (default: cpu)| -|`nodeId` | String or String[] or Boolean | 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| - - -### cluster.nodeInfo() - -http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`all` | Boolean | Return all available information| -|`clear` | Boolean | Reset the default settings| -|`http` | Boolean | Return information about HTTP| -|`jvm` | Boolean | Return information about the JVM| -|`network` | Boolean | Return information about network| -|`os` | Boolean | Return information about the operating system| -|`plugin` | Boolean | Return information about plugins| -|`process` | Boolean | Return information about the Elasticsearch process| -|`settings` | Boolean | Return information about node settings| -|`threadPool` | Boolean | Return information about the thread pool| -|`timeout` | Date or Number | Explicit operation timeout| -|`transport` | Boolean | Return information about transport| -|`nodeId` | String or String[] or Boolean | 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| - - -### cluster.nodeShutdown() - -http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`delay` | Date or Number | Set the delay for the operation (default: 1s)| -|`exit` | Boolean | Exit the JVM as well (default: true)| -|`nodeId` | String or String[] or Boolean | A comma-separated list of node IDs or names to perform the operation on; use `_local` to perform the operation on the node you're connected to, leave empty to perform the operation on all nodes| - - -### cluster.nodeStats() - -http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-stats/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`all` | Boolean | Return all available information| -|`clear` | Boolean | Reset the default level of detail| -|`fields` | String or String[] or Boolean | A comma-separated list of fields to return detailed information for, when returning the `indices` metric family (supports wildcards)| -|`fs` | Boolean | Return information about the filesystem| -|`http` | Boolean | Return information about HTTP| -|`indices` | Boolean | Return information about indices| -|`jvm` | Boolean | Return information about the JVM| -|`network` | Boolean | Return information about network| -|`os` | Boolean | Return information about the operating system| -|`process` | Boolean | Return information about the Elasticsearch process| -|`threadPool` | Boolean | Return information about the thread pool| -|`transport` | Boolean | Return information about transport| -|`metricFamily` | String | Limit the information returned to a certain metric family| -|`metric` | String | Limit the information returned for `indices` family to a specific metric| -|`nodeId` | String or String[] or Boolean | 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| - - -### cluster.putSettings() - -http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/ - --- none -- - - -### cluster.reroute() - -http://elasticsearch.org/guide/reference/api/admin-cluster-reroute/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`dryRun` | Boolean | Simulate the operation only and return the resulting state| -|`filterMetadata` | Boolean | Don't return cluster state metadata (default: false)| - - -### cluster.state() - -http://elasticsearch.org/guide/reference/api/admin-cluster-state/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`filterBlocks` | Boolean | Do not return information about blocks| -|`filterIndexTemplates` | Boolean | Do not return information about index templates| -|`filterIndices` | String or String[] or Boolean | Limit returned metadata information to specific indices| -|`filterMetadata` | Boolean | Do not return information about indices metadata| -|`filterNodes` | Boolean | Do not return information about nodes| -|`filterRoutingTable` | Boolean | Do not return information about shard allocation (`routing_table` and `routing_nodes`)| -|`local` | Boolean | Return local information, do not retrieve the state from master node (default: false)| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| - - -### count() - -http://elasticsearch.org/guide/reference/api/count/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`minScore` | Number | Include only documents with a specific `_score` value in the result| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`routing` | String | Specific routing value| -|`source` | String | The URL-encoded query definition (instead of using the request body)| -|`index` | String or String[] or Boolean | A comma-separated list of indices to restrict the results| -|`type` | String or String[] or Boolean | A comma-separated list of types to restrict the results| - - -### create() - -http://elasticsearch.org/guide/reference/api/index_/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`consistency` | String | Explicit write consistency setting for the operation| -|`id` | String | Document ID| -|`parent` | String | ID of the parent document| -|`percolate` | String | Percolator queries to execute while indexing the document| -|`refresh` | Boolean | Refresh the index after performing the operation| -|`[replication=sync]` | String | Specific replication type| -|`routing` | String | Specific routing value| -|`timeout` | Date or Number | Explicit operation timeout| -|`timestamp` | Date or Number | Explicit timestamp for the document| -|`ttl` | Duration | Expiration time for the document| -|`version` | Number | Explicit version number for concurrency control| -|`versionType` | String | Specific version type| -|`index` | String | The name of the index| -|`type` | String | The type of the document| - - -### delete() - -http://elasticsearch.org/guide/reference/api/delete/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`consistency` | String | Specific write consistency setting for the operation| -|`parent` | String | ID of parent document| -|`refresh` | Boolean | Refresh the index after performing the operation| -|`[replication=sync]` | String | Specific replication type| -|`routing` | String | Specific routing value| -|`timeout` | Date or Number | Explicit operation timeout| -|`version` | Number | Explicit version number for concurrency control| -|`versionType` | String | Specific version type| -|`id` | String | The document ID| -|`index` | String | The name of the index| -|`type` | String | The type of the document| - - -### deleteByQuery() - -http://www.elasticsearch.org/guide/reference/api/delete-by-query/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`analyzer` | String | The analyzer to use for the query string| -|`consistency` | String | Specific write consistency setting for the operation| -|`[defaultOperator=OR]` | String | The default operator for query string query (AND or OR)| -|`df` | String | The field to use as default where no field prefix is given in the query string| -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`[replication=sync]` | String | Specific replication type| -|`q` | String | Query in the Lucene query string syntax| -|`routing` | String | Specific routing value| -|`source` | String | The URL-encoded query definition (instead of using the request body)| -|`timeout` | Date or Number | Explicit operation timeout| -|`index` | String or String[] or Boolean | A comma-separated list of indices to restrict the operation; use `_all` to perform the operation on all indices| -|`type` | String or String[] or Boolean | A comma-separated list of types to restrict the operation| - - -### exists() - -http://elasticsearch.org/guide/reference/api/get/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`parent` | String | The ID of the parent document| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`realtime` | Boolean | Specify whether to perform the operation in realtime or search mode| -|`refresh` | Boolean | Refresh the shard containing the document before performing the operation| -|`routing` | String | Specific routing value| -|`id` | String | The document ID| -|`index` | String | The name of the index| -|`[type=_all]` | String | The type of the document (use `_all` to fetch the first document matching the ID across all types)| - - -### explain() - -http://elasticsearch.org/guide/reference/api/explain/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`analyzeWildcard` | Boolean | Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)| -|`analyzer` | String | The analyzer for the query string query| -|`[defaultOperator=OR]` | String | The default operator for query string query (AND or OR)| -|`df` | String | The default field for query string query (default: _all)| -|`fields` | String or String[] or Boolean | A comma-separated list of fields to return in the response| -|`lenient` | Boolean | Specify whether format-based query failures (such as providing text to a numeric field) should be ignored| -|`lowercaseExpandedTerms` | Boolean | Specify whether query terms should be lowercased| -|`parent` | String | The ID of the parent document| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`q` | String | Query in the Lucene query string syntax| -|`routing` | String | Specific routing value| -|`source` | String or String[] or Boolean | True or false to return the _source field or not, or a list of fields to return| -|`sourceExclude` | String or String[] or Boolean | A list of fields to exclude from the returned _source field| -|`sourceInclude` | String or String[] or Boolean | A list of fields to extract and return from the _source field| -|`id` | String | The document ID| -|`index` | String | The name of the index| -|`type` | String | The type of the document| - - -### get() - -http://elasticsearch.org/guide/reference/api/get/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`fields` | String or String[] or Boolean | A comma-separated list of fields to return in the response| -|`parent` | String | The ID of the parent document| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`realtime` | Boolean | Specify whether to perform the operation in realtime or search mode| -|`refresh` | Boolean | Refresh the shard containing the document before performing the operation| -|`routing` | String | Specific routing value| -|`source` | String or String[] or Boolean | True or false to return the _source field or not, or a list of fields to return| -|`sourceExclude` | String or String[] or Boolean | A list of fields to exclude from the returned _source field| -|`sourceInclude` | String or String[] or Boolean | A list of fields to extract and return from the _source field| -|`id` | String | The document ID| -|`index` | String | The name of the index| -|`[type=_all]` | String | The type of the document (use `_all` to fetch the first document matching the ID across all types)| - - -### getSource() - -http://elasticsearch.org/guide/reference/api/get/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`exclude` | String or String[] or Boolean | A list of fields to exclude from the returned _source field| -|`include` | String or String[] or Boolean | A list of fields to extract and return from the _source field| -|`parent` | String | The ID of the parent document| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`realtime` | Boolean | Specify whether to perform the operation in realtime or search mode| -|`refresh` | Boolean | Refresh the shard containing the document before performing the operation| -|`routing` | String | Specific routing value| -|`id` | String | The document ID| -|`index` | String | The name of the index| -|`[type=_all]` | String | The type of the document; use `_all` to fetch the first document matching the ID across all types| - - -### index() - -http://elasticsearch.org/guide/reference/api/index_/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`consistency` | String | Explicit write consistency setting for the operation| -|`[opType=index]` | String | Explicit operation type| -|`parent` | String | ID of the parent document| -|`percolate` | String | Percolator queries to execute while indexing the document| -|`refresh` | Boolean | Refresh the index after performing the operation| -|`[replication=sync]` | String | Specific replication type| -|`routing` | String | Specific routing value| -|`timeout` | Date or Number | Explicit operation timeout| -|`timestamp` | Date or Number | Explicit timestamp for the document| -|`ttl` | Duration | Expiration time for the document| -|`version` | Number | Explicit version number for concurrency control| -|`versionType` | String | Specific version type| -|`id` | String | Document ID| -|`index` | String | The name of the index| -|`type` | String | The type of the document| - - -### indices.analyze() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`analyzer` | String | The name of the analyzer to use| -|`field` | String | Use the analyzer configured for this field (instead of passing the analyzer name)| -|`filters` | String or String[] or Boolean | A comma-separated list of filters to use for the analysis| -|`index` | String | The name of the index to scope the operation| -|`preferLocal` | Boolean | With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)| -|`text` | String | The text on which the analysis should be performed (when request body is not used)| -|`tokenizer` | String | The name of the tokenizer to use for the analysis| -|`[format=detailed]` | String | Format of the output| - - -### indices.clearCache() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`fieldData` | Boolean | Clear field data| -|`fielddata` | Boolean | Clear field data| -|`fields` | String or String[] or Boolean | A comma-separated list of fields to clear when using the `field_data` parameter (default: all)| -|`filter` | Boolean | Clear filter caches| -|`filterCache` | Boolean | Clear filter caches| -|`filterKeys` | Boolean | A comma-separated list of keys to clear when using the `filter_cache` parameter (default: all)| -|`id` | Boolean | Clear ID caches for parent/child| -|`idCache` | Boolean | Clear ID caches for parent/child| -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`index` | String or String[] or Boolean | A comma-separated list of index name to limit the operation| -|`recycler` | Boolean | Clear the recycler cache| - - -### indices.close() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit operation timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String | The name of the index| - - -### indices.create() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit operation timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String | The name of the index| - - -### indices.delete() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-index/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit operation timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String or String[] or Boolean | A comma-separated list of indices to delete; use `_all` or empty string to delete all indices| - - -### indices.deleteAlias() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit timestamp for the document| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String | The name of the index with an alias| -|`name` | String | The name of the alias to be deleted| - - -### indices.deleteMapping() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` for all indices| -|`type` | String | The name of the document type to delete| - - -### indices.deleteTemplate() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit operation timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`name` | String | The name of the template| - - -### indices.deleteWarmer() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String or String[] or Boolean | A comma-separated list of index names to register warmer for; use `_all` or empty string to perform the operation on all indices| -|`name` | String | The name of the warmer (supports wildcards); leave empty to delete all warmers| -|`type` | String or String[] or Boolean | A comma-separated list of document types to register warmer for; use `_all` or empty string to perform the operation on all types| - - -### indices.exists() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-indices-exists/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`index` | String or String[] or Boolean | A comma-separated list of indices to check| - - -### indices.existsAlias() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`index` | String or String[] or Boolean | A comma-separated list of index names to filter aliases| -|`name` | String or String[] or Boolean | A comma-separated list of alias names to return| - - -### indices.existsType() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-types-exists/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` to check the types across all indices| -|`type` | String or String[] or Boolean | A comma-separated list of document types to check| - - -### indices.flush() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-flush/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`force` | Boolean | TODO: ?| -|`full` | Boolean | TODO: ?| -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`refresh` | Boolean | Refresh the index after performing the operation| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string for all indices| - - -### indices.getAlias() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`index` | String or String[] or Boolean | A comma-separated list of index names to filter aliases| -|`name` | String or String[] or Boolean | A comma-separated list of alias names to return| - - -### indices.getAliases() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit operation timeout| -|`index` | String or String[] or Boolean | A comma-separated list of index names to filter aliases| - - -### indices.getFieldMapping() - -http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`includeDefaults` | Boolean | Whether the default mapping values should be returned as well| -|`index` | String or String[] or Boolean | A comma-separated list of index names| -|`type` | String or String[] or Boolean | A comma-separated list of document types| -|`field` | String or String[] or Boolean | A comma-separated list of fields| - - -### indices.getMapping() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`index` | String or String[] or Boolean | A comma-separated list of index names| -|`type` | String or String[] or Boolean | A comma-separated list of document types| - - -### indices.getSettings() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-get-settings/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices| - - -### indices.getTemplate() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`name` | String | The name of the template| - - -### indices.getWarmer() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`index` | String or String[] or Boolean | A comma-separated list of index names to restrict the operation; use `_all` to perform the operation on all indices| -|`name` | String | The name of the warmer (supports wildcards); leave empty to get all warmers| -|`type` | String or String[] or Boolean | A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types| - - -### indices.open() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit operation timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String | The name of the index| - - -### indices.optimize() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`flush` | Boolean | Specify whether the index should be flushed after performing the operation (default: true)| -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`maxNumSegments` | Number | The number of segments the index should be merged into (default: dynamic)| -|`onlyExpungeDeletes` | Boolean | Specify whether the operation should only expunge deleted documents| -|`operationThreading` | * | TODO: ?| -|`refresh` | Boolean | Specify whether the index should be refreshed after performing the operation (default: true)| -|`waitForMerge` | Boolean | Specify whether the request should block until the merge process is finished (default: true)| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices| - - -### indices.putAlias() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Explicit timestamp for the document| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String | The name of the index with an alias| -|`name` | String | The name of the alias to be created or updated| - - -### indices.putMapping() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`ignoreConflicts` | Boolean | Specify whether to ignore conflicts while updating the mapping (default: false)| -|`timeout` | Date or Number | Explicit operation timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` to perform the operation on all indices| -|`type` | String | The name of the document type| - - -### indices.putSettings() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices| - - -### indices.putTemplate() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`order` | Number | The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)| -|`timeout` | Date or Number | Explicit operation timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`name` | String | The name of the template| - - -### indices.putWarmer() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String or String[] or Boolean | A comma-separated list of index names to register the warmer for; use `_all` or empty string to perform the operation on all indices| -|`name` | String | The name of the warmer| -|`type` | String or String[] or Boolean | A comma-separated list of document types to register the warmer for; leave empty to perform the operation on all types| - - -### indices.refresh() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`operationThreading` | * | TODO: ?| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices| - - -### indices.segments() - -http://elasticsearch.org/guide/reference/api/admin-indices-segments/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`operationThreading` | * | TODO: ?| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices| - - -### indices.snapshotIndex() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string for all indices| - - -### indices.stats() - -http://elasticsearch.org/guide/reference/api/admin-indices-stats/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`all` | Boolean | Return all available information| -|`clear` | Boolean | Reset the default level of detail| -|`completion` | Boolean | Return information about completion suggester stats| -|`completionFields` | String or String[] or Boolean | A comma-separated list of fields for `completion` metric (supports wildcards)| -|`docs` | Boolean | Return information about indexed and deleted documents| -|`fielddata` | Boolean | Return information about field data| -|`fielddataFields` | String or String[] or Boolean | A comma-separated list of fields for `fielddata` metric (supports wildcards)| -|`fields` | String or String[] or Boolean | A comma-separated list of fields to return detailed information for, when returning the `search` statistics| -|`filterCache` | Boolean | Return information about filter cache| -|`flush` | Boolean | Return information about flush operations| -|`get` | Boolean | Return information about get operations| -|`groups` | Boolean | A comma-separated list of search groups for `search` statistics| -|`idCache` | Boolean | Return information about ID cache| -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`indexing` | Boolean | Return information about indexing operations| -|`merge` | Boolean | Return information about merge operations| -|`refresh` | Boolean | Return information about refresh operations| -|`search` | Boolean | Return information about search operations; use the `groups` parameter to include information for specific search groups| -|`store` | Boolean | Return information about the size of the index| -|`warmer` | Boolean | Return information about warmers| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices| -|`indexingTypes` | String or String[] or Boolean | A comma-separated list of document types to include in the `indexing` statistics| -|`metricFamily` | String | Limit the information returned to a specific metric| -|`searchGroups` | String or String[] or Boolean | A comma-separated list of search groups to include in the `search` statistics| - - -### indices.status() - -http://elasticsearch.org/guide/reference/api/admin-indices-status/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`operationThreading` | * | TODO: ?| -|`recovery` | Boolean | Return information about shard recovery| -|`snapshot` | Boolean | TODO: ?| -|`index` | String or String[] or Boolean | A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices| - - -### indices.updateAliases() - -http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`timeout` | Date or Number | Request timeout| -|`masterTimeout` | Date or Number | Specify timeout for connection to master| -|`index` | String or String[] or Boolean | A comma-separated list of index names to filter aliases| - - -### indices.validateQuery() - -http://www.elasticsearch.org/guide/reference/api/validate/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`explain` | Boolean | Return detailed information about the error| -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`operationThreading` | * | TODO: ?| -|`source` | String | The URL-encoded query definition (instead of using the request body)| -|`q` | String | Query in the Lucene query string syntax| -|`index` | String or String[] or Boolean | A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices| -|`type` | String or String[] or Boolean | A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types| - - -### info() - -http://elasticsearch.org/guide/ - --- none -- - - -### mget() - -http://elasticsearch.org/guide/reference/api/multi-get/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`fields` | String or String[] or Boolean | A comma-separated list of fields to return in the response| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`realtime` | Boolean | Specify whether to perform the operation in realtime or search mode| -|`refresh` | Boolean | Refresh the shard containing the document before performing the operation| -|`source` | String or String[] or Boolean | True or false to return the _source field or not, or a list of fields to return| -|`sourceExclude` | String or String[] or Boolean | A list of fields to exclude from the returned _source field| -|`sourceInclude` | String or String[] or Boolean | A list of fields to extract and return from the _source field| -|`index` | String | The name of the index| -|`type` | String | The type of the document| - - -### mlt() - -http://elasticsearch.org/guide/reference/api/more-like-this/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`boostTerms` | Number | The boost factor| -|`maxDocFreq` | Number | The word occurrence frequency as count: words with higher occurrence in the corpus will be ignored| -|`maxQueryTerms` | Number | The maximum query terms to be included in the generated query| -|`maxWordLen` | Number | The minimum length of the word: longer words will be ignored| -|`minDocFreq` | Number | The word occurrence frequency as count: words with lower occurrence in the corpus will be ignored| -|`minTermFreq` | Number | The term frequency as percent: terms with lower occurence in the source document will be ignored| -|`minWordLen` | Number | The minimum length of the word: shorter words will be ignored| -|`mltFields` | String or String[] or Boolean | Specific fields to perform the query against| -|`percentTermsToMatch` | Number | How many terms have to match in order to consider the document a match (default: 0.3)| -|`routing` | String | Specific routing value| -|`searchFrom` | Number | The offset from which to return results| -|`searchIndices` | String or String[] or Boolean | A comma-separated list of indices to perform the query against (default: the index containing the document)| -|`searchQueryHint` | String | The search query hint| -|`searchScroll` | String | A scroll search request definition| -|`searchSize` | Number | The number of documents to return (default: 10)| -|`searchSource` | String | A specific search request definition (instead of using the request body)| -|`searchType` | String | Specific search type (eg. `dfs_then_fetch`, `count`, etc)| -|`searchTypes` | String or String[] or Boolean | A comma-separated list of types to perform the query against (default: the same type as the document)| -|`stopWords` | String or String[] or Boolean | A list of stop words to be ignored| -|`id` | String | The document ID| -|`index` | String | The name of the index| -|`type` | String | The type of the document (use `_all` to fetch the first document matching the ID across all types)| - - -### msearch() - -http://www.elasticsearch.org/guide/reference/api/multi-search/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`searchType` | String | Search operation type| -|`index` | String or String[] or Boolean | A comma-separated list of index names to use as default| -|`type` | String or String[] or Boolean | A comma-separated list of document types to use as default| - - -### percolate() - -http://elasticsearch.org/guide/reference/api/percolate/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`preferLocal` | Boolean | With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)| -|`index` | String | The name of the index with a registered percolator query| -|`type` | String | The document type| - - -### scroll() - -http://www.elasticsearch.org/guide/reference/api/search/scroll/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`scroll` | Duration | Specify how long a consistent view of the index should be maintained for scrolled search| -|`scrollId` | String | The scroll ID| - - -### search() - -http://www.elasticsearch.org/guide/reference/api/search/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`analyzer` | String | The analyzer to use for the query string| -|`analyzeWildcard` | Boolean | Specify whether wildcard and prefix queries should be analyzed (default: false)| -|`[defaultOperator=OR]` | String | The default operator for query string query (AND or OR)| -|`df` | String | The field to use as default where no field prefix is given in the query string| -|`explain` | Boolean | Specify whether to return detailed information about score computation as part of a hit| -|`fields` | String or String[] or Boolean | A comma-separated list of fields to return as part of a hit| -|`from` | Number | Starting offset (default: 0)| -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`indicesBoost` | String or String[] or Boolean | Comma-separated list of index boosts| -|`lenient` | Boolean | Specify whether format-based query failures (such as providing text to a numeric field) should be ignored| -|`lowercaseExpandedTerms` | Boolean | Specify whether query terms should be lowercased| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`q` | String | Query in the Lucene query string syntax| -|`routing` | String or String[] or 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| -|`size` | Number | Number of hits to return (default: 10)| -|`sort` | String or String[] or Boolean | A comma-separated list of : pairs| -|`source` | String or String[] or Boolean | True or false to return the _source field or not, or a list of fields to return| -|`sourceExclude` | String or String[] or Boolean | A list of fields to exclude from the returned _source field| -|`sourceInclude` | String or String[] or Boolean | A list of fields to extract and return from the _source field| -|`stats` | String or String[] or Boolean | Specific 'tag' of the request for logging and statistical purposes| -|`suggestField` | String | Specify which field to use for suggestions| -|`[suggestMode=missing]` | String | Specify suggest mode| -|`suggestSize` | Number | How many suggestions to return in response| -|`suggestText` | Text | The source text for which the suggestions should be returned| -|`timeout` | Date or Number | Explicit operation timeout| -|`version` | Boolean | Specify whether to return document version as part of a hit| -|`[index=_all]` | String or String[] or Boolean | A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices| -|`type` | String or String[] or Boolean | A comma-separated list of document types to search; leave empty to perform the operation on all types| - - -### suggest() - -http://elasticsearch.org/guide/reference/api/search/suggest/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`[ignoreIndices=none]` | String | When performed on multiple indices, allows to ignore `missing` ones| -|`preference` | String | Specify the node or shard the operation should be performed on (default: random)| -|`routing` | String | Specific routing value| -|`source` | String | The URL-encoded request definition (instead of using request body)| -|`index` | String or String[] or Boolean | A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices| - - -### update() - -http://elasticsearch.org/guide/reference/api/update/ - -| Name | Type | Description | -| ---- | ---- | ----------- | -|`consistency` | String | Explicit write consistency setting for the operation| -|`fields` | String or String[] or Boolean | A comma-separated list of fields to return in the response| -|`lang` | String | The script language (default: mvel)| -|`parent` | String | ID of the parent document| -|`percolate` | String | Perform percolation during the operation; use specific registered query name, attribute, or wildcard| -|`refresh` | Boolean | Refresh the index after performing the operation| -|`[replication=sync]` | String | Specific replication type| -|`retryOnConflict` | Number | Specify how many times should the operation be retried when a conflict occurs (default: 0)| -|`routing` | String | Specific routing value| -|`script` | * | The URL-encoded script definition (instead of using request body)| -|`timeout` | Date or Number | Explicit operation timeout| -|`timestamp` | Date or Number | Explicit timestamp for the document| -|`ttl` | Duration | Expiration time for the document| -|`version` | Number | Explicit version number for concurrency control| -|`versionType` | String | Specific version type| -|`id` | String | Document ID| -|`index` | String | The name of the index| -|`type` | String | The type of the document| - diff --git a/docs/configuration.md b/docs/configuration.md deleted file mode 100644 index d488598fc..000000000 --- a/docs/configuration.md +++ /dev/null @@ -1,117 +0,0 @@ - -The `Client` constructor accepts a single object as it's argument, and the following keys can be used to configure that client instance: - -```js -var elasticsearch = require('elasticsearch'); -var es = new elasticsearch.Client({ - ... -}); -``` - -### hosts -Type: `String`, `String[]` or `Object[]` - -Default: -```js -hosts: [ - { - host: 'localhost', port: '9200', protocol: 'http' - } -] -``` - -Specify the list of hosts that this client will connect to. If sniffing is enabled, or you call sniff, this list will be used as seeds for discovery of the rest of the cluster. - -### log -Type: `String`, `String[]`, `Object`, `Object[]`, or `Constructor` - -Default: -```js -log: { - type: 'stdio', - levels: ['error', 'warning'] -} -``` - -Unless a constructor is specified, this sets the output settings for the bundled logger. See [setting up logging](docs/setting_up_logging.md) for more information. - -### connectionClass -Type: `String`, `Constructor` - -Default: - - Node: `'http'` - - Browser: `'xhr'` - - Angular Build: `'angular'` - - jQuery Build: `'jquery'` - -Defines the class that will be used to create connections. If you are looking to implement a protocol besides HTTP you will probably start by writing a Connection class and specifying it here. - -### selector -Type: `String`, `Function` - -Default: `'roundRobin'` - -Options: - - `'roundRobin'` - - `'random'` - -This function will be used to select a connection from the ConnectionPool. It should received a single argument, the list of "active" connections, and return the connection to use. Use this selector to implement special logic for your client such as preferring nodes in a certain rack or data-center. - -To make this function asynchronous, accept a second argument which will be the callback to use. The callback should be called Node-style, with a possible error like `cb(err, selectedConnection)`. - -### sniffOnStart -Type: `Boolean` - -Default: `false` - -Should the client attempt to detect the rest of the cluster when it is first instantiated? - -### sniffAfterRequests -Type: `Number` or `false` - -Default: `false` - -After `n` requests, perform a sniff operation and ensure our list of nodes is up to date. - - -### sniffOnConnectionFail -Type: `Boolean` - -Default: `false` - -Should the client immediately sniff for a more current list of nodes when a connection dies? (see [node death](#node-death)) - -### maxRetries -Type: `Number` - -Defailt: `3` - -How many times should the client try to connect to other nodes before returning a [ConnectionFault](docs/error.md#connectionfault) error. (see [node death](#node-death)) - -### timeout -Type: `Number` - -Default: 10000 - -How many milliseconds can the connection take before the request is aborted and retried. (TODO: timeout errors shouldn't cause a retry). - -### deadTimeout -Type: `Number` - -Default: 30000 - -How many milliseconds should a dead connection/node sit and wait before it is ping-ed? (see [node death](#node-death)) - -### maxSockets -Type: `Number` - -Default: 10 - -How many sockets should a connection keep to it's corresponding Elasticsearch node? These sockets are currently kept alive ***forever*** (not like nodes current "keep alive" sockets). - -### nodesToHostCallback -Type: `Function` - -Default: simple, not much going on [here](src/lib/client_config.js#L65). - -This function will receive a list of nodes received during a sniff. The list of nodes should be transformed into an array of objects which will each be used to create [Host](src/lib/host.js) objects. (TODO: allow this function to be async). diff --git a/docs/customize_logging.md b/docs/customize_logging.md deleted file mode 100644 index f599c789a..000000000 --- a/docs/customize_logging.md +++ /dev/null @@ -1,3 +0,0 @@ -# Customize Logging - -TODO: what are loggers, how to use bunyan/winston diff --git a/docs/errors.md b/docs/errors.md deleted file mode 100644 index f9f0fa5fd..000000000 --- a/docs/errors.md +++ /dev/null @@ -1,39 +0,0 @@ -# Errors - -These are the standard Error types which may be passed back from the client. To access the constructors access the errors module via `require('elasticsearch').errors`. - -## ConnectionFault -The connection was unable to initiate or complete a request with the Elasticsearch node. - -## NoConnections -All of the connections in the ConnectionPool are dead. - -## RequestTimeout -The request timed-out. - -## Serialization -The response received from Elasticsearch could not be deserilaized. - -## 503 or ServiceUnavailable -Elasticsearch responded with a 503 status. - -## 500 or InternalServerError -Elasticsearch responded with a 500 status. - -## 412 or PreconditionFailed -Elasticsearch responded with a 412 status. - -## 409 or Conflict -Elasticsearch responded with a 409 status. - -## 403 or Forbidden -Elasticsearch responded with a 403 status. - -## 404 or NotFound -Elasticsearch responded with a 404 status. - -## 400 or BadRequest -Elasticsearch responded with a 400 status. - -## Generic -Elasticsearch responded with a status that does not map to it's own error type. diff --git a/docs/examples.md b/docs/examples.md deleted file mode 100644 index 0a2a78498..000000000 --- a/docs/examples.md +++ /dev/null @@ -1,52 +0,0 @@ -### Examples -#### create the client -```js -var es = new elasticsearch.Client({ - hosts: [ - 'localhost:9200' - ], - log: 'trace', - sniffOnStart: true -}); -``` -#### call an endpoint -```js -es.cluster.nodeInfo({ - clear: true, - jvm: true, - os: ture -}, function (err, resp, status) { - // do your thing -}) -``` -#### skip the callback to get a promise back -```js -es.search({ - q: 'pants' -}).then(function (resp) { - // use resp.body and resp.status -}, function (err) { - // freak out! -}) -``` -#### abort a request -```js -var req = es.search({ - q: 'robots' -}, function (err, body, status) { - clearTimeout(timeout); - // do something -}); -var timeout = setTimeout(function () { - req.abort(); -}, 200); -``` -#### or just use the timeout param -```js -es.search({ - q: '*', - timeout: 200 -}).then(function (resp) { - // Iterate all the hits -}) -``` diff --git a/docs/replacing_core_components.md b/docs/replacing_core_components.md deleted file mode 100644 index f219f32cd..000000000 --- a/docs/replacing_core_components.md +++ /dev/null @@ -1,11 +0,0 @@ -# Replacing Core Components - -TODO: detail the components that are replaceable - -## API - -## Connection - -## ConnectionPool - -## Log diff --git a/log b/log new file mode 100644 index 000000000..740e6d701 --- /dev/null +++ b/log @@ -0,0 +1,1218 @@ +INFO: 2013-11-26T23:46:02Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:46:02Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:46:02Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:46:02Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:46:02Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:46:02Z + Request complete + +TRACE: 2013-11-26T23:46:02Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:46:02Z + Request complete + +TRACE: 2013-11-26T23:46:02Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:46:02Z + Request complete + +DEBUG: 2013-11-26T23:46:02Z + starting request { method: 'POST', + bulkBody: true, + path: '/_bulk', + body: + [ { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T08:02:51.510Z', + ip: '120.221.62.6', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T08:02:51.510Z', + referer: 'http://undefined/undefined/kenneth-reightler', + agent: undefined, + clientip: '120.221.62.6', + bytes: 0, + request: '/yvonne-cagle.undefined', + memory: 0, + '@message': '120.221.62.6 - - [2013-11-25T08:02:51.510Z] "GET /yvonne-cagle.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.25",\n "@timestamp": "2013-11-25T08:02:51.510Z",\n "ip": "120.221.62.6",\n "point": [\n 45.85285,\n -106.7092722\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-25T08:02:51.510Z",\n "referer": "http://undefined/undefined/kenneth-reightler",\n "clientip": "120.221.62.6",\n "bytes": 0,\n "request": "/yvonne-cagle.undefined",\n "memory": 0,\n "@message": "120.221.62.6 - - [2013-11-25T08:02:51.510Z] \\"GET /yvonne-cagle.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.27', + '@timestamp': '2013-11-27T15:03:15.201Z', + ip: '85.69.11.58', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-27T15:03:15.201Z', + referer: 'http://undefined/undefined/aleksandr-misurkin', + agent: undefined, + clientip: '85.69.11.58', + bytes: 0, + request: '/william-pogue.undefined', + memory: 0, + '@message': '85.69.11.58 - - [2013-11-27T15:03:15.201Z] "GET /william-pogue.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.27",\n "@timestamp": "2013-11-27T15:03:15.201Z",\n "ip": "85.69.11.58",\n "point": [\n 43.03172639,\n -78.16759972\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-27T15:03:15.201Z",\n "referer": "http://undefined/undefined/aleksandr-misurkin",\n "clientip": "85.69.11.58",\n "bytes": 0,\n "request": "/william-pogue.undefined",\n "memory": 0,\n "@message": "85.69.11.58 - - [2013-11-27T15:03:15.201Z] \\"GET /william-pogue.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T11:30:17.094Z', + ip: '228.64.134.25', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T11:30:17.094Z', + referer: 'http://undefined/undefined/valery-korzun', + agent: undefined, + clientip: '228.64.134.25', + bytes: 0, + request: '/petr-klimuk.undefined', + memory: 0, + '@message': '228.64.134.25 - - [2013-11-26T11:30:17.094Z] "GET /petr-klimuk.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.26",\n "@timestamp": "2013-11-26T11:30:17.094Z",\n "ip": "228.64.134.25",\n "point": [\n 37.06290556,\n -120.8692511\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-26T11:30:17.094Z",\n "referer": "http://undefined/undefined/valery-korzun",\n "clientip": "228.64.134.25",\n "bytes": 0,\n "request": "/petr-klimuk.undefined",\n "memory": 0,\n "@message": "228.64.134.25 - - [2013-11-26T11:30:17.094Z] \\"GET /petr-klimuk.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T18:38:43.020Z', + ip: '17.20.110.74', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T18:38:43.020Z', + referer: 'http://undefined/undefined/takuya-onishi', + agent: undefined, + clientip: '17.20.110.74', + bytes: 0, + request: '/georgi-beregovoi.undefined', + memory: 0, + '@message': '17.20.110.74 - - [2013-11-26T18:38:43.020Z] "GET /georgi-beregovoi.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.26",\n "@timestamp": "2013-11-26T18:38:43.020Z",\n "ip": "17.20.110.74",\n "point": [\n 35.83186111,\n -90.64616667\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-26T18:38:43.020Z",\n "referer": "http://undefined/undefined/takuya-onishi",\n "clientip": "17.20.110.74",\n "bytes": 0,\n "request": "/georgi-beregovoi.undefined",\n "memory": 0,\n "@message": "17.20.110.74 - - [2013-11-26T18:38:43.020Z] \\"GET /georgi-beregovoi.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.28', + '@timestamp': '2013-11-28T11:31:07.776Z', + ip: '133.160.55.75', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-28T11:31:07.776Z', + referer: 'http://undefined/undefined/sergei-krikalev', + agent: undefined, + clientip: '133.160.55.75', + bytes: 0, + request: '/gregory-chamitoff.undefined', + memory: 0, + '@message': '133.160.55.75 - - [2013-11-28T11:31:07.776Z] "GET /gregory-chamitoff.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.28",\n "@timestamp": "2013-11-28T11:31:07.776Z",\n "ip": "133.160.55.75",\n "point": [\n 47.26793111,\n -122.5780997\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-28T11:31:07.776Z",\n "referer": "http://undefined/undefined/sergei-krikalev",\n "clientip": "133.160.55.75",\n "bytes": 0,\n "request": "/gregory-chamitoff.undefined",\n "memory": 0,\n "@message": "133.160.55.75 - - [2013-11-28T11:31:07.776Z] \\"GET /gregory-chamitoff.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.27', + '@timestamp': '2013-11-27T15:20:02.074Z', + ip: '221.154.189.120', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-27T15:20:02.074Z', + referer: 'http://undefined/undefined/dominic-a-antonelli', + agent: undefined, + clientip: '221.154.189.120', + bytes: 0, + request: '/f-drew-gaffney.undefined', + memory: 0, + '@message': '221.154.189.120 - - [2013-11-27T15:20:02.074Z] "GET /f-drew-gaffney.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.27",\n "@timestamp": "2013-11-27T15:20:02.074Z",\n "ip": "221.154.189.120",\n "point": [\n 40.94752444,\n -74.31450139\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-27T15:20:02.074Z",\n "referer": "http://undefined/undefined/dominic-a-antonelli",\n "clientip": "221.154.189.120",\n "bytes": 0,\n "request": "/f-drew-gaffney.undefined",\n "memory": 0,\n "@message": "221.154.189.120 - - [2013-11-27T15:20:02.074Z] \\"GET /f-drew-gaffney.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T15:49:12.558Z', + ip: '27.150.116.119', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T15:49:12.558Z', + referer: 'http://undefined/undefined/sally-ride', + agent: undefined, + clientip: '27.150.116.119', + bytes: 0, + request: '/mol.undefined', + memory: 0, + '@message': '27.150.116.119 - - [2013-11-25T15:49:12.558Z] "GET /mol.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.25",\n "@timestamp": "2013-11-25T15:49:12.558Z",\n "ip": "27.150.116.119",\n "point": [\n 45.93179639,\n -89.26906778\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-25T15:49:12.558Z",\n "referer": "http://undefined/undefined/sally-ride",\n "clientip": "27.150.116.119",\n "bytes": 0,\n "request": "/mol.undefined",\n "memory": 0,\n "@message": "27.150.116.119 - - [2013-11-25T15:49:12.558Z] \\"GET /mol.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T15:39:47.735Z', + ip: '175.120.83.94', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T15:39:47.735Z', + referer: 'http://undefined/undefined/anna-lee-fisher', + agent: undefined, + clientip: '175.120.83.94', + bytes: 0, + request: '/joseph-p-allen.undefined', + memory: 0, + '@message': '175.120.83.94 - - [2013-11-26T15:39:47.735Z] "GET /joseph-p-allen.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.26",\n "@timestamp": "2013-11-26T15:39:47.735Z",\n "ip": "175.120.83.94",\n "point": [\n 37.95825861,\n -119.1065375\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-26T15:39:47.735Z",\n "referer": "http://undefined/undefined/anna-lee-fisher",\n "clientip": "175.120.83.94",\n "bytes": 0,\n "request": "/joseph-p-allen.undefined",\n "memory": 0,\n "@message": "175.120.83.94 - - [2013-11-26T15:39:47.735Z] \\"GET /joseph-p-allen.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T13:38:36.878Z', + ip: '152.119.250.67', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T13:38:36.878Z', + referer: 'http://undefined/undefined/aleksandar-panayotov-aleksandrov', + agent: undefined, + clientip: '152.119.250.67', + bytes: 0, + request: '/edward-gibson.undefined', + memory: 0, + '@message': '152.119.250.67 - - [2013-11-26T13:38:36.878Z] "GET /edward-gibson.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.26",\n "@timestamp": "2013-11-26T13:38:36.878Z",\n "ip": "152.119.250.67",\n "point": [\n 33.45370806,\n -93.99102\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-26T13:38:36.878Z",\n "referer": "http://undefined/undefined/aleksandar-panayotov-aleksandrov",\n "clientip": "152.119.250.67",\n "bytes": 0,\n "request": "/edward-gibson.undefined",\n "memory": 0,\n "@message": "152.119.250.67 - - [2013-11-26T13:38:36.878Z] \\"GET /edward-gibson.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' }, + { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T16:25:58.391Z', + ip: '71.248.43.132', + extension: undefined, + response: undefined, + country: undefined, + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T16:25:58.391Z', + referer: 'http://undefined/undefined/charles-hobaugh', + agent: undefined, + clientip: '71.248.43.132', + bytes: 0, + request: '/koichi-wakata.undefined', + memory: 0, + '@message': '71.248.43.132 - - [2013-11-25T16:25:58.391Z] "GET /koichi-wakata.undefined HTTP/1.1" undefined 0 "-" "undefined"', + src: '{\n "index": "logstash-2013.11.25",\n "@timestamp": "2013-11-25T16:25:58.391Z",\n "ip": "71.248.43.132",\n "point": [\n 42.71720944,\n -71.12343\n ],\n "@tags": [\n null,\n null\n ],\n "utc_time": "2013-11-25T16:25:58.391Z",\n "referer": "http://undefined/undefined/charles-hobaugh",\n "clientip": "71.248.43.132",\n "bytes": 0,\n "request": "/koichi-wakata.undefined",\n "memory": 0,\n "@message": "71.248.43.132 - - [2013-11-25T16:25:58.391Z] \\"GET /koichi-wakata.undefined HTTP/1.1\\" undefined 0 \\"-\\" \\"undefined\\""\n}' } ], + query: {} } + + +TRACE: 2013-11-26T23:46:02Z + <- 500 + { + "error": "ActionRequestValidationException[Validation Failed: 1: type is missing;2: type is missing;3: type is missing;4: type is missing;5: type is missing;6: type is missing;7: type is missing;8: type is missing;9: type is missing;10: type is missing;]", + "status": 500 + } + +INFO: 2013-11-26T23:46:02Z + Request complete + +INFO: 2013-11-26T23:50:05Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:50:05Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:50:05Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:50:05Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:50:05Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:50:05Z + Request complete + +TRACE: 2013-11-26T23:50:05Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:50:05Z + Request complete + +TRACE: 2013-11-26T23:50:05Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:50:05Z + Request complete + +INFO: 2013-11-26T23:52:08Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:52:08Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:52:08Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:52:08Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:52:08Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:08Z + Request complete + +TRACE: 2013-11-26T23:52:08Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:08Z + Request complete + +TRACE: 2013-11-26T23:52:08Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:08Z + Request complete + +INFO: 2013-11-26T23:52:26Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:52:26Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:52:26Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:52:26Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:52:26Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:26Z + Request complete + +TRACE: 2013-11-26T23:52:26Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:26Z + Request complete + +TRACE: 2013-11-26T23:52:26Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:26Z + Request complete + +INFO: 2013-11-26T23:52:39Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:52:39Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:52:39Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:52:39Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:52:39Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:39Z + Request complete + +TRACE: 2013-11-26T23:52:39Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:39Z + Request complete + +TRACE: 2013-11-26T23:52:39Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:52:39Z + Request complete + +INFO: 2013-11-26T23:53:25Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:53:25Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:53:25Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:53:25Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:53:25Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:53:25Z + Request complete + +TRACE: 2013-11-26T23:53:25Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:53:25Z + Request complete + +TRACE: 2013-11-26T23:53:25Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:53:25Z + Request complete + +INFO: 2013-11-26T23:53:51Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:53:51Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:53:51Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:53:51Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:53:51Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:53:51Z + Request complete + +TRACE: 2013-11-26T23:53:51Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:53:51Z + Request complete + +TRACE: 2013-11-26T23:53:51Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:53:51Z + Request complete + +DEBUG: 2013-11-26T23:53:51Z + starting request { method: 'POST', + bulkBody: true, + path: '/_bulk', + body: + [ { index: [Object] }, + { index: 'logstash-2013.11.27', + '@timestamp': '2013-11-27T11:01:46.464Z', + ip: '218.93.172.84', + extension: 'html', + response: '200', + country: 'IN', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-27T11:01:46.464Z', + referer: 'http://twitter.com/success/salizhan-sharipov', + agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1', + clientip: '218.93.172.84', + bytes: 7224.210747866891, + request: '/catherine-coleman.html', + memory: 0, + '@message': '218.93.172.84 - - [2013-11-27T11:01:46.464Z] "GET /catherine-coleman.html HTTP/1.1" 200 7224.210747866891 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T11:22:26.066Z', + ip: '230.179.185.98', + extension: 'png', + response: '200', + country: 'CL', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T11:22:26.066Z', + referer: 'http://www.slate.com/success/james-adamson', + agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1', + clientip: '230.179.185.98', + bytes: 6029.147767811082, + request: '/john-l-finley.png', + memory: 0, + '@message': '230.179.185.98 - - [2013-11-26T11:22:26.066Z] "GET /john-l-finley.png HTTP/1.1" 200 6029.147767811082 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T12:01:03.453Z', + ip: '235.106.100.46', + extension: 'html', + response: '200', + country: 'IN', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T12:01:03.453Z', + referer: 'http://www.slate.com/success/jack-lousma', + agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)', + clientip: '235.106.100.46', + bytes: 1878.2579940743744, + request: '/yuri-baturin.html', + memory: 0, + '@message': '235.106.100.46 - - [2013-11-26T12:01:03.453Z] "GET /yuri-baturin.html HTTP/1.1" 200 1878.2579940743744 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"' }, + { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T08:34:28.985Z', + ip: '41.184.254.139', + extension: 'php', + response: '200', + country: 'ET', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T08:34:28.985Z', + referer: 'http://facebook.com/success/kenneth-ham', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '41.184.254.139', + bytes: 8498.210506164469, + request: '/aleksandr-balandin.php', + memory: 339928.42024657875, + phpmemory: 339928.42024657875, + '@message': '41.184.254.139 - - [2013-11-25T08:34:28.985Z] "GET /aleksandr-balandin.php HTTP/1.1" 200 8498.210506164469 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T11:24:08.080Z', + ip: '104.13.55.87', + extension: 'html', + response: '200', + country: 'DE', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T11:24:08.080Z', + referer: 'http://twitter.com/success/soichi-noguchi', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '104.13.55.87', + bytes: 6399.783093831502, + request: '/patricia-robertson.html', + memory: 0, + '@message': '104.13.55.87 - - [2013-11-26T11:24:08.080Z] "GET /patricia-robertson.html HTTP/1.1" 200 6399.783093831502 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.27', + '@timestamp': '2013-11-27T15:11:12.638Z', + ip: '214.72.27.161', + extension: 'php', + response: '200', + country: 'BR', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-27T15:11:12.638Z', + referer: 'http://facebook.com/warning/undefined', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '214.72.27.161', + bytes: 2954.7709771431983, + request: '/sergei-avdeyev.php', + memory: 118190.83908572793, + phpmemory: 118190.83908572793, + '@message': '214.72.27.161 - - [2013-11-27T15:11:12.638Z] "GET /sergei-avdeyev.php HTTP/1.1" 200 2954.7709771431983 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.27', + '@timestamp': '2013-11-27T15:50:15.171Z', + ip: '82.237.31.179', + extension: 'html', + response: '200', + country: 'IN', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-27T15:50:15.171Z', + referer: 'http://www.slate.com/success/alexander-kaleri', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '82.237.31.179', + bytes: 9767.629058100283, + request: '/maurizio-cheli.html', + memory: 0, + '@message': '82.237.31.179 - - [2013-11-27T15:50:15.171Z] "GET /maurizio-cheli.html HTTP/1.1" 200 9767.629058100283 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T13:23:18.412Z', + ip: '166.229.6.80', + extension: 'html', + response: '200', + country: 'BD', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T13:23:18.412Z', + referer: 'http://www.slate.com/error/yuri-gidzenko', + agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)', + clientip: '166.229.6.80', + bytes: 9016.587681602687, + request: '/michael-massimino.html', + memory: 0, + '@message': '166.229.6.80 - - [2013-11-25T13:23:18.412Z] "GET /michael-massimino.html HTTP/1.1" 200 9016.587681602687 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T06:44:40.845Z', + ip: '255.44.120.41', + extension: 'html', + response: '200', + country: 'ES', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T06:44:40.845Z', + referer: 'http://www.slate.com/success/sultan-bin-salman-bin-abdulaziz-al-saud', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '255.44.120.41', + bytes: 4735.908680013381, + request: '/stephen-thorne.html', + memory: 0, + '@message': '255.44.120.41 - - [2013-11-26T06:44:40.845Z] "GET /stephen-thorne.html HTTP/1.1" 200 4735.908680013381 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T10:09:16.609Z', + ip: '185.97.92.201', + extension: 'html', + response: '200', + country: 'IQ', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T10:09:16.609Z', + referer: 'http://www.slate.com/success/sheikh-muszaphar-shukor', + agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)', + clientip: '185.97.92.201', + bytes: 4091.87903359998, + request: '/john-herrington.html', + memory: 0, + '@message': '185.97.92.201 - - [2013-11-25T10:09:16.609Z] "GET /john-herrington.html HTTP/1.1" 200 4091.87903359998 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"' } ], + query: {} } + + +TRACE: 2013-11-26T23:53:51Z + <- 200 + { + "took": 22, + "items": [ + { + "index": { + "_index": "logstash-2013.11.27", + "_type": "apache", + "_id": "0", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "apache", + "_id": "1", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "apache", + "_id": "2", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.25", + "_type": "apache", + "_id": "3", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "apache", + "_id": "4", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.27", + "_type": "nginx", + "_id": "5", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.27", + "_type": "apache", + "_id": "6", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.25", + "_type": "apache", + "_id": "7", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "nginx", + "_id": "8", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.25", + "_type": "apache", + "_id": "9", + "_version": 1, + "ok": true + } + } + ] + } + +INFO: 2013-11-26T23:53:51Z + Request complete + +INFO: 2013-11-26T23:54:11Z + Adding connection to http://localhost:9200/ + +DEBUG: 2013-11-26T23:54:11Z + starting request { method: 'POST', + path: '/logstash-2013.11.25', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:54:11Z + starting request { method: 'POST', + path: '/logstash-2013.11.26', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +DEBUG: 2013-11-26T23:54:11Z + starting request { method: 'POST', + path: '/logstash-2013.11.27', + ignore: [ 400 ], + body: { mappings: { _default_: [Object] } }, + query: {} } + + +TRACE: 2013-11-26T23:54:11Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.25] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:54:11Z + Request complete + +TRACE: 2013-11-26T23:54:11Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.26] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:54:11Z + Request complete + +TRACE: 2013-11-26T23:54:11Z + <- 400 + { + "error": "IndexAlreadyExistsException[[logstash-2013.11.27] Already exists]", + "status": 400 + } + +INFO: 2013-11-26T23:54:11Z + Request complete + +DEBUG: 2013-11-26T23:54:11Z + starting request { method: 'POST', + bulkBody: true, + path: '/_bulk', + body: + [ { index: [Object] }, + { index: 'logstash-2013.11.27', + '@timestamp': '2013-11-27T15:39:05.030Z', + ip: '0.150.148.105', + extension: 'php', + response: '404', + country: 'US', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-27T15:39:05.030Z', + referer: 'http://www.slate.com/success/terrence-wilcutt', + agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1', + clientip: '0.150.148.105', + bytes: 9390.817967010662, + request: '/anatoly-solovyev.php', + memory: 375632.7186804265, + phpmemory: 375632.7186804265, + '@message': '0.150.148.105 - - [2013-11-27T15:39:05.030Z] "GET /anatoly-solovyev.php HTTP/1.1" 404 9390.817967010662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T14:54:55.623Z', + ip: '90.201.21.178', + extension: 'html', + response: '200', + country: 'PT', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T14:54:55.623Z', + referer: 'http://facebook.com/success/brian-duffy', + agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1', + clientip: '90.201.21.178', + bytes: 9904.669359675609, + request: '/charles-fullerton.html', + memory: 0, + '@message': '90.201.21.178 - - [2013-11-26T14:54:55.623Z] "GET /charles-fullerton.html HTTP/1.1" 200 9904.669359675609 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"' }, + { index: [Object] }, + { index: 'logstash-2013.11.27', + '@timestamp': '2013-11-27T11:29:01.987Z', + ip: '16.212.152.97', + extension: 'php', + response: '200', + country: 'US', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-27T11:29:01.987Z', + referer: 'http://twitter.com/success/mikhail-korniyenko', + agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1', + clientip: '16.212.152.97', + bytes: 6684.905453235842, + request: '/russell-l-rogers.php', + memory: 267396.2181294337, + phpmemory: 267396.2181294337, + '@message': '16.212.152.97 - - [2013-11-27T11:29:01.987Z] "GET /russell-l-rogers.php HTTP/1.1" 200 6684.905453235842 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T12:28:04.774Z', + ip: '71.202.115.53', + extension: 'html', + response: '200', + country: 'ID', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T12:28:04.774Z', + referer: 'http://www.slate.com/warning/konstantin-feoktistov', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '71.202.115.53', + bytes: 7482.41366550792, + request: '/daniel-bursch.html', + memory: 0, + '@message': '71.202.115.53 - - [2013-11-26T12:28:04.774Z] "GET /daniel-bursch.html HTTP/1.1" 200 7482.41366550792 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T10:09:18.719Z', + ip: '208.26.147.73', + extension: 'css', + response: '200', + country: 'CN', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T10:09:18.719Z', + referer: 'http://www.slate.com/success/mike-adams', + agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1', + clientip: '208.26.147.73', + bytes: 4383.4871660219505, + request: '/jay-c-buckey.css', + memory: 0, + '@message': '208.26.147.73 - - [2013-11-26T10:09:18.719Z] "GET /jay-c-buckey.css HTTP/1.1" 200 4383.4871660219505 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"' }, + { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T12:36:43.252Z', + ip: '138.171.19.140', + extension: 'gif', + response: '200', + country: 'ID', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T12:36:43.252Z', + referer: 'http://twitter.com/success/john-o-creighton', + agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1', + clientip: '138.171.19.140', + bytes: 5994.4642026675865, + request: '/dumitru-prunariu.gif', + memory: 0, + '@message': '138.171.19.140 - - [2013-11-25T12:36:43.252Z] "GET /dumitru-prunariu.gif HTTP/1.1" 200 5994.4642026675865 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"' }, + { index: [Object] }, + { index: 'logstash-2013.11.25', + '@timestamp': '2013-11-25T08:26:49.178Z', + ip: '50.208.203.18', + extension: 'png', + response: '200', + country: 'IN', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-25T08:26:49.178Z', + referer: 'http://www.slate.com/success/william-s-mcarthur', + agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)', + clientip: '50.208.203.18', + bytes: 4402.547343051992, + request: '/mae-jemison.png', + memory: 0, + '@message': '50.208.203.18 - - [2013-11-25T08:26:49.178Z] "GET /mae-jemison.png HTTP/1.1" 200 4402.547343051992 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T13:24:45.487Z', + ip: '122.245.207.254', + extension: 'php', + response: '200', + country: 'CH', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T13:24:45.487Z', + referer: 'http://twitter.com/success/robert-l-gibson', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '122.245.207.254', + bytes: 8718.007877236232, + request: '/ted-freeman.php', + memory: 348720.3150894493, + phpmemory: 348720.3150894493, + '@message': '122.245.207.254 - - [2013-11-26T13:24:45.487Z] "GET /ted-freeman.php HTTP/1.1" 200 8718.007877236232 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.26', + '@timestamp': '2013-11-26T17:50:35.300Z', + ip: '118.71.12.139', + extension: 'html', + response: '200', + country: 'IN', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-26T17:50:35.300Z', + referer: 'http://twitter.com/error/gemini-7', + agent: 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', + clientip: '118.71.12.139', + bytes: 9250.977833173238, + request: '/viktor-m-afanasyev.html', + memory: 0, + '@message': '118.71.12.139 - - [2013-11-26T17:50:35.300Z] "GET /viktor-m-afanasyev.html HTTP/1.1" 200 9250.977833173238 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"' }, + { index: [Object] }, + { index: 'logstash-2013.11.28', + '@timestamp': '2013-11-28T09:52:19.767Z', + ip: '180.180.149.134', + extension: 'php', + response: '200', + country: 'CN', + point: [Object], + '@tags': [Object], + utc_time: '2013-11-28T09:52:19.767Z', + referer: 'http://twitter.com/warning/richard-linnehan', + agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)', + clientip: '180.180.149.134', + bytes: 9082.738787168637, + request: '/scott-altman.php', + memory: 363309.5514867455, + phpmemory: 363309.5514867455, + '@message': '180.180.149.134 - - [2013-11-28T09:52:19.767Z] "GET /scott-altman.php HTTP/1.1" 200 9082.738787168637 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"' } ], + query: {} } + + +TRACE: 2013-11-26T23:54:11Z + <- 200 + { + "took": 10, + "items": [ + { + "index": { + "_index": "logstash-2013.11.27", + "_type": "apache", + "_id": "0", + "_version": 2, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "apache", + "_id": "1", + "_version": 2, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.27", + "_type": "apache", + "_id": "2", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "apache", + "_id": "3", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "nginx", + "_id": "4", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.25", + "_type": "nginx", + "_id": "5", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.25", + "_type": "apache", + "_id": "6", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "apache", + "_id": "7", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.26", + "_type": "apache", + "_id": "8", + "_version": 1, + "ok": true + } + }, + { + "index": { + "_index": "logstash-2013.11.28", + "_type": "apache", + "_id": "9", + "_version": 1, + "ok": true + } + } + ] + } + +INFO: 2013-11-26T23:54:11Z + Request complete + diff --git a/package.json b/package.json index a4005067b..b801b9c9d 100644 --- a/package.json +++ b/package.json @@ -44,21 +44,19 @@ "when": "~2.6.0", "lodash": "~2.3.0", "agentkeepalive": "~0.1", - "chalk": "~0.3.0", - "inherits": "~2.0.1" + "chalk": "~0.3.0" }, "scripts": { "test": "node scripts/run_tests.js", "coverage": "mocha test/unit/test_*.js --require blanket -R html-cov > coverage.html && open -a \"Google Chrome\" ./coverage.html", "build": "grunt", "generate": "node scripts/generate/js_api && node scripts/generate/yaml_tests", - "export_client": "node scripts/export_client.js", "blanket": { "pattern": "src" } }, "testling": { "harness": "mocha", - "files": "test/unit/test_!(http_connection|stdio_logger).js" + "files": "test/unit/test_!(http_connector|stdio_logger).js" } } diff --git a/scripts/export_client.js b/scripts/export_client.js index 59a645953..daf68249b 100644 --- a/scripts/export_client.js +++ b/scripts/export_client.js @@ -14,7 +14,7 @@ var argv = require('optimist') o: 'outputDir', v: 'verbose' }) - .parse(JSON.parse(process.env.npm_config_argv).original); + .argv; switch (argv.buildName) { case 'jquery': diff --git a/scripts/export_docs.js b/scripts/export_docs.js new file mode 100644 index 000000000..43b3749e3 --- /dev/null +++ b/scripts/export_docs.js @@ -0,0 +1,96 @@ +var path = require('path'); +var fs = require('fs'); +var format = require('util').format; +var cp = require('child_process'); + +var argv = require('optimist') + .default({ + outputDir: '.', + verbose: false + }) + .alias({ + o: 'outputDir', + v: 'verbose' + }) + .argv; + +var steps = [ + [runInModule, 'node', [path.join(__dirname, './generate/js_api'), '--force']], + [ + copy, + path.join(__dirname, '../docs/_methods.jade'), + path.join(argv.outputDir, '_methods.jade') + ], + [ + copy, + path.join(__dirname, '../docs/_method_list.jade'), + path.join(argv.outputDir, '_method_list.jade') + ] +]; + +(function next() { + var step = steps.shift(); + if (step) { + var fn = step.shift(); + step.push(next); + fn.apply(null, step); + } else { + console.log('Done'); + process.exit(); + } +})(); + +function log() { + var out = format.apply(console, arguments); + if (argv.verbose) { + out = '\n' + out + '\n'; + } + console.log(out); +} + +function runInModule(cmd, args, exitCb) { + log('running', cmd, args.join(' ')); + + var proc = cp.spawn(cmd, args, { + stdio: argv.verbose ? 'inherit' : 'ignore' + }); + + proc.on('error', function (err) { + console.error('Error! --', err.message); + process.exit(1); + }); + + proc.on('exit', function (status) { + if (status) { + console.error('Error! --', cmd, 'exit status was', status); + process.exit(1); + } else { + exitCb(); + } + }); +} + +function copy(from, to, done) { + log('copying', from, 'to', to); + + var read = fs.createReadStream(from); + var write = fs.createWriteStream(to); + + read.pipe(write); + + read.on('error', function (err) { + console.error('unable to read: ' + from); + console.error(err.message); + process.exit(1); + }); + + write.on('error', function (err) { + console.error('unable to write to: ' + to); + console.error(err.message); + process.exit(1); + }); + + write.on('finish', function () { + done(); + }); +} diff --git a/scripts/generate/js_api/actions.js b/scripts/generate/js_api/actions.js index 833eb2c22..0fd0c8552 100644 --- a/scripts/generate/js_api/actions.js +++ b/scripts/generate/js_api/actions.js @@ -198,24 +198,43 @@ function transformFile(entry) { /** * un-comment to print out the default method for any action that has multiple options */ -// module.exports = new EventEmitter(); +module.exports = new EventEmitter(); // module.exports.on('ready', function (actions) { // var longestName = 0; -// var lines = []; +// var reports = { +// multi_methods: [], +// get_with_body: [] +// }; // actions.forEach(function (action) { +// var name; + // // console.log(action); // if (action._methods.length > 1) { -// var name = action.name + ' (' + action._methods.join('/') + ')'; +// name = action.name + ' (' + action._methods.join('/') + ')'; // longestName = Math.max(name.length, longestName); -// lines.push([name, action.spec.method || 'GET', action.docUrl]); +// reports.multi_methods.push([name, action.spec.method || 'GET', action.docUrl]); +// } + +// if (action._methods.length === 1 && action._methods[0] === 'GET' && action.body) { +// name = action.name + ' (' + action._methods.join('/') + ')'; +// longestName = Math.max(name.length, longestName); +// reports.get_with_body.push([name, action.spec.method || 'GET', action.docUrl]); // } // }); -// lines.forEach(function (line) { -// var name = line[0]; -// var def = line[1]; -// var docUrl = line[2]; -// var spacing = (new Array(longestName - name.length + 1)).join(' '); -// console.log(name + spacing + ' [' + def + (def.length === 3 ? ' ' : '') + '] -> ' + docUrl); +// Object.keys(reports).forEach(function (key) { +// console.log('\n' + key); +// if (reports[key].length) { +// reports[key].forEach(function (line) { +// var name = line[0]; +// var def = line[1]; +// var docUrl = line[2]; +// var spacing = (new Array(longestName - name.length + 1)).join(' '); +// console.log(name + spacing + ' [' + def + (def.length === 3 ? ' ' : '') + '] -> ' + docUrl); +// }); +// } else { +// console.log('--nada--'); +// } +// console.log('\n'); // }); // }); diff --git a/scripts/generate/js_api/index.js b/scripts/generate/js_api/index.js index 8409e904a..890aa7ed3 100644 --- a/scripts/generate/js_api/index.js +++ b/scripts/generate/js_api/index.js @@ -5,7 +5,7 @@ var clean = require('../../clean'); var restSpecUpdated = require('../../rest_spec_updated'); var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js'); -var docOutputPath = _.joinPath(__dirname, '../../../docs/api.md'); +var docOutputDir = _.joinPath(__dirname, '../../../docs/'); function download() { require('./actions').on('ready', function (actions) { @@ -32,14 +32,22 @@ function download() { namespaces: _.unique(namespaces.sort(), true) })); - fs.writeFileSync(docOutputPath, templates.apiDocs({ + if (!fs.existsSync(docOutputDir)) { + fs.mkdirSync(docOutputDir); + } + + fs.writeFileSync(docOutputDir + '_method_list.jade', templates.apiMethodList({ + actions: actions + })); + + fs.writeFileSync(docOutputDir + '_methods.jade', templates.apiMethods({ actions: actions })); }); } restSpecUpdated(function (err, updated) { - if (process.env.FORCE_GEN || process.env.npm_config_force || err || updated) { + if (err || updated) { download(); } }); diff --git a/scripts/generate/js_api/templates/api_docs.tmpl b/scripts/generate/js_api/templates/api_docs.tmpl deleted file mode 100644 index 023687ff2..000000000 --- a/scripts/generate/js_api/templates/api_docs.tmpl +++ /dev/null @@ -1,62 +0,0 @@ -# API - -## Table Of Contents - - - [Generic Params](#generic-params) - - [Methods](#methods)<% - -function esc(str) { - return str.replace(/\|/g, '|'); -} - -var _paramWithDefault = paramWithDefault; -paramWithDefault = function (name, _default) { - return esc(_paramWithDefault(name, _default)); -}; - -var _paramType = paramType; -paramType = function (type) { - return esc(_paramType(type)); -}; - -_.each(actions, function (action) {%> - - [<%= action.name %>](#<%= action.name.toLowerCase().replace(/[^\w ]/g, '').replace(/ /g, '-') %>)<% -}) - -%> - -## Generic Params - -Several parameters can be passed to any API method, and will control the way that those requests are carried out. These parameters are not listed in each method's param list. - -| Name | Type | Description | -| ---- | ---- | ----------- | -| `[timeout=10000]` | Number | The number of milliseconds this request has to complete. It defaults to the timeout specified at the client level, which defaults to 10 seconds. | -| `ignore` | Number or Number[] | Don't treat these HTTP status codes as "errors". Example use cases could be `ignore: 404` or `ignore: [404]` | - -## Methods<% - -_.each(actions, function (action) { -%> - -### <%= action.name %>() - -<%= action.docUrl %><% - -if (_.size(action.allParams)) { %> - -| Name | Type | Description | -| ---- | ---- | ----------- | -<% - _.each(action.allParams, function(param, paramName) { -%>|`<%= paramWithDefault(paramName, param.default) %>` | <%= paramType(param.type) %> | <%= esc(param.description || '') %>| -<% }) - -} else {%> - --- none -- -<% - -} - -}); %> diff --git a/scripts/generate/js_api/templates/api_method_list.tmpl b/scripts/generate/js_api/templates/api_method_list.tmpl new file mode 100644 index 000000000..a304f70e5 --- /dev/null +++ b/scripts/generate/js_api/templates/api_method_list.tmpl @@ -0,0 +1,32 @@ +<% +function esc(str) { + return str.replace(/\|/g, '|'); +} + +var topActions = []; +var names = {}; + +_.each(actions, function (action) { + if (action.name.indexOf('.') > -1) { + var space = _.studlyCase(action.name.split('.').slice(0, -1).join('.')); + if (!names[space]) { + names[space] = []; + } + names[space].push(action); + } else { + topActions.push(action); + } +}); %> + +ul<% +_.each(topActions, function (action) {%> + li: a(href="api.html#<%= action.name.toLowerCase().replace(/[^\w]+/g, '-') %>") <%= action.name %><% +}); +_.each(Object.keys(names).sort(), function (namespace) {%> + h3 <%= namespace %> + ul<% + _.each(names[namespace], function (action) {%> + li: a(href="api.html#<%= action.name.toLowerCase().replace(/[^\w]+/g, '-') %>") <%= action.name.replace(/^.*\./, '') %><% + }) +}) +%> diff --git a/scripts/generate/js_api/templates/api_methods.tmpl b/scripts/generate/js_api/templates/api_methods.tmpl new file mode 100644 index 000000000..3236d3a5f --- /dev/null +++ b/scripts/generate/js_api/templates/api_methods.tmpl @@ -0,0 +1,40 @@ +<% +_.each(actions, function (action) { +var actionId = action.name.toLowerCase().replace(/[^\w]+/g, '-'); + +%> + +h3#<%= actionId %>.fn + span.name <%= action.name %> + span.args (params, [callback]) +a.perma(href="api.html#<%= actionId %>", title="Permalink") +a.esdoc(href="<%= action.docUrl %>", title="Endpoint Docs") +// + h4 Spec: + pre + code <%= JSON.stringify(action, null, ' ').split('\n').map(function (line, i) { + return (i > 0 ? ' | ' : '') + line; + }).join('\n') %> + +h4 Params: +ul.params.api +<% _.each(action.allParams, function (param, paramName) { %> + li + code.name <%= paramWithDefault(paramName, param.default) %> + <%= + _.map( + ('' + paramType(param.type) + ' ' + (param.description || '')).split('\n'), + function (line) { + return '| ' + line + '\n'; + } + ).join('\n') + %> +<% }); %> + li the usual + +h4 Method: <%= action.spec.method || 'GET' %> + +h4 Returns: +p: a(href="#api-conventions-return") the usual<% +}); +%> diff --git a/scripts/generate/js_api/templates/index.js b/scripts/generate/js_api/templates/index.js index 30ce1b230..ce1ffab75 100644 --- a/scripts/generate/js_api/templates/index.js +++ b/scripts/generate/js_api/templates/index.js @@ -52,13 +52,13 @@ var templateGlobals = { paramType: function (type) { switch (type && type.toLowerCase ? type.toLowerCase() : 'any') { case 'time': - return 'Date or Number'; + return 'Date, Number'; case 'any': - return '*'; + return 'Anything'; case 'enum': return 'String'; case 'list': - return 'String or String[] or Boolean'; + return 'String, String[], Boolean'; default: return _.ucfirst(type); } @@ -91,5 +91,6 @@ templates.text = templates.string; module.exports = { apiFile: templates.api_file, - apiDocs: templates.api_docs + apiMethodList: templates.api_method_list, + apiMethods: templates.api_methods }; diff --git a/scripts/generate/logs/index.js b/scripts/generate/logs/index.js index 834417265..099400b03 100644 --- a/scripts/generate/logs/index.js +++ b/scripts/generate/logs/index.js @@ -8,7 +8,7 @@ var argv = require('optimist') default: 14000 }, days: { - alias: 'c', + alias: 'd', type: 'number', required: true }, @@ -22,22 +22,21 @@ var argv = require('optimist') // Error.stackTraceLimit = Infinity; // process.exit(); -var count = parseInt(argv._[0] || 14000, 10), - days = parseInt(argv._[1] || 7, 10); - -var es = require('../../../src/elasticsearch'), - _ = require('../../../src/lib/utils'), - async = require('async'), - moment = require('moment'), - makeSamples = require('./samples').make, - startingMoment = moment().startOf('day').subtract('days', days), - endingMoment = moment().endOf('day').add('days', days), - clientConfig = { - log: { - level: 'trace', - type: 'stdio' - } - }; +var es = require('../../../src/elasticsearch'); +var _ = require('../../../src/lib/utils'); +var async = require('async'); +var path = require('path'); +var moment = require('moment'); +var makeSamples = require('./samples').make; +var startingMoment = moment().startOf('day').subtract('days', argv.days); +var endingMoment = moment().endOf('day').add('days', argv.days); +var clientConfig = { + log: { + level: 'trace', + type: 'file', + path: path.join(__dirname, '../../../log') + } +}; if (argv.host) { clientConfig.hosts = argv.host; @@ -47,13 +46,13 @@ if (argv.host) { var client = new es.Client(clientConfig); -console.log('Generating', count, 'events across ±', days, 'days'); +console.log('Generating', argv.count, 'events across ±', argv.days, 'days'); fillIndecies(function () { - var actions = [], - samples = makeSamples(startingMoment, endingMoment); + var actions = []; + var samples = makeSamples(startingMoment, endingMoment); - async.times(count, function (i, done) { + async.times(argv.count, function (i, done) { // random date, plus less random time var date = moment(samples.randomMsInDayRange()) .utc() @@ -84,7 +83,6 @@ fillIndecies(function () { event['@message'] = event.ip + ' - - [' + date.toISOString() + '] "GET ' + event.request + ' HTTP/1.1" ' + event.response + ' ' + event.bytes + ' "-" "' + event.agent + '"'; - event.src = JSON.stringify(event, null, ' '); actions.push({ index: { @@ -95,7 +93,7 @@ fillIndecies(function () { }); actions.push(event); - if (actions.length === 3000 || i === count - 1) { + if (actions.length === 3000 || i === argv.count - 1) { console.info('writing', actions.length / 2, 'documents'); client.bulk({ body: actions @@ -109,6 +107,7 @@ fillIndecies(function () { throw err; } else { console.log('Done!'); + process.exit(); } }); }); diff --git a/scripts/generate/logs/samples/countries.js b/scripts/generate/logs/samples/countries.js deleted file mode 100644 index d158da110..000000000 --- a/scripts/generate/logs/samples/countries.js +++ /dev/null @@ -1,250 +0,0 @@ -module.exports = { - 'CN': 1330044000, - 'IN': 1173108018, - 'US': 610232863, - 'ID': 242968342, - 'BR': 201103330, - 'PK': 184404791, - 'BD': 156118464, - 'NG': 154000000, - 'RU': 140702000, - 'JP': 127288000, - 'MX': 112468855, - 'PH': 99900177, - 'VN': 89571130, - 'ET': 88013491, - 'DE': 81802257, - 'EG': 80471869, - 'TR': 77804122, - 'IR': 76923300, - 'CD': 70916439, - 'TH': 67089500, - 'FR': 64768389, - 'GB': 62348447, - 'IT': 60340328, - 'MM': 53414374, - 'ZA': 49000000, - 'KR': 48422644, - 'ES': 46505963, - 'UA': 45415596, - 'CO': 44205293, - 'TZ': 41892895, - 'AR': 41343201, - 'KE': 40046566, - 'PL': 38500000, - 'SD': 35000000, - 'DZ': 34586184, - 'CA': 33679000, - 'UG': 33398682, - 'MA': 31627428, - 'PE': 29907003, - 'IQ': 29671605, - 'AF': 29121286, - 'NP': 28951852, - 'MY': 28274729, - 'UZ': 27865738, - 'VE': 27223228, - 'SA': 25731776, - 'GH': 24339838, - 'YE': 23495361, - 'KP': 22912177, - 'TW': 22894384, - 'SY': 22198110, - 'MZ': 22061451, - 'RO': 21959278, - 'AU': 21515754, - 'LK': 21513990, - 'MG': 21281844, - 'CI': 21058798, - 'CM': 19294149, - 'CL': 16746491, - 'NL': 16645000, - 'BF': 16241811, - 'NE': 15878271, - 'MW': 15447500, - 'KZ': 15340000, - 'EC': 14790608, - 'KH': 14453680, - 'ML': 13796354, - 'GT': 13550440, - 'ZM': 13460305, - 'AO': 13068161, - 'SN': 12323252, - 'ZW': 11651858, - 'CU': 11423000, - 'RW': 11055976, - 'GR': 11000000, - 'CS': 10829175, - 'PT': 10676000, - 'TN': 10589025, - 'TD': 10543464, - 'CZ': 10476000, - 'BE': 10403000, - 'GN': 10324025, - 'SO': 10112453, - 'BO': 9947418, - 'HU': 9930000, - 'BI': 9863117, - 'DO': 9823821, - 'BY': 9685000, - 'HT': 9648924, - 'BJ': 9056010, - 'SE': 9045000, - 'AZ': 8303512, - 'SS': 8260490, - 'AT': 8205000, - 'HN': 7989415, - 'CH': 7581000, - 'TJ': 7487489, - 'IL': 7353985, - 'RS': 7344847, - 'BG': 7148785, - 'HK': 6898686, - 'TG': 6587239, - 'LY': 6461454, - 'JO': 6407085, - 'PY': 6375830, - 'LA': 6368162, - 'PG': 6064515, - 'SV': 6052064, - 'NI': 5995928, - 'ER': 5792984, - 'KG': 5508626, - 'DK': 5484000, - 'SK': 5455000, - 'SL': 5245695, - 'FI': 5244000, - 'NO': 5009150, - 'AE': 4975593, - 'TM': 4940916, - 'CF': 4844927, - 'SG': 4701069, - 'GE': 4630000, - 'IE': 4622917, - 'BA': 4590000, - 'CR': 4516220, - 'HR': 4491000, - 'MD': 4324000, - 'NZ': 4252277, - 'LB': 4125247, - 'PR': 3916632, - 'PS': 3800000, - 'LR': 3685076, - 'LT': 3565000, - 'UY': 3477000, - 'PA': 3410676, - 'MR': 3205060, - 'MN': 3086918, - 'CG': 3039126, - 'AL': 2986952, - 'AM': 2968000, - 'OM': 2967717, - 'JM': 2847232, - 'KW': 2789132, - 'LV': 2217969, - 'NA': 2128471, - 'MK': 2061000, - 'BW': 2029307, - 'SI': 2007000, - 'LS': 1919552, - 'XK': 1800000, - 'GM': 1593256, - 'GW': 1565126, - 'GA': 1545255, - 'SZ': 1354051, - 'MU': 1294104, - 'EE': 1291170, - 'TT': 1228691, - 'TL': 1154625, - 'CY': 1102677, - 'GQ': 1014999, - 'FJ': 875983, - 'QA': 840926, - 'RE': 776948, - 'KM': 773407, - 'GY': 748486, - 'DJ': 740528, - 'BH': 738004, - 'BT': 699847, - 'ME': 666730, - 'SB': 559198, - 'CV': 508659, - 'LU': 497538, - 'SR': 492829, - 'MO': 449198, - 'GP': 443000, - 'MQ': 432900, - 'MT': 403000, - 'MV': 395650, - 'BN': 395027, - 'BZ': 314522, - 'IS': 308910, - 'BS': 301790, - 'BB': 285653, - 'EH': 273008, - 'PF': 270485, - 'VU': 221552, - 'NC': 216494, - 'GF': 195506, - 'WS': 192001, - 'ST': 175808, - 'LC': 160922, - 'GU': 159358, - 'YT': 159042, - 'CW': 141766, - 'AN': 136197, - 'TO': 122580, - 'VI': 108708, - 'GD': 107818, - 'FM': 107708, - 'VC': 104217, - 'KI': 92533, - 'JE': 90812, - 'SC': 88340, - 'AG': 86754, - 'AD': 84000, - 'IM': 75049, - 'DM': 72813, - 'AW': 71566, - 'MH': 65859, - 'BM': 65365, - 'GG': 65228, - 'AS': 57881, - 'GL': 56375, - 'MP': 53883, - 'KN': 49898, - 'FO': 48228, - 'KY': 44270, - 'SX': 37429, - 'MF': 35925, - 'LI': 35000, - 'MC': 32965, - 'SM': 31477, - 'GI': 27884, - 'AX': 26711, - 'VG': 21730, - 'CK': 21388, - 'TC': 20556, - 'PW': 19907, - 'BQ': 18012, - 'WF': 16025, - 'AI': 13254, - 'TV': 10472, - 'NR': 10065, - 'MS': 9341, - 'BL': 8450, - 'SH': 7460, - 'PM': 7012, - 'IO': 4000, - 'FK': 2638, - 'SJ': 2550, - 'NU': 2166, - 'NF': 1828, - 'CX': 1500, - 'TK': 1466, - 'VA': 921, - 'CC': 628, - 'TF': 140, - 'PN': 46, - 'GS': 30 -}; diff --git a/scripts/generate/logs/samples/countries.json b/scripts/generate/logs/samples/countries.json new file mode 100644 index 000000000..ea535447e --- /dev/null +++ b/scripts/generate/logs/samples/countries.json @@ -0,0 +1,250 @@ +{ + "CN": 1330044000, + "IN": 1173108018, + "US": 610232863, + "ID": 242968342, + "BR": 201103330, + "PK": 184404791, + "BD": 156118464, + "NG": 154000000, + "RU": 140702000, + "JP": 127288000, + "MX": 112468855, + "PH": 99900177, + "VN": 89571130, + "ET": 88013491, + "DE": 81802257, + "EG": 80471869, + "TR": 77804122, + "IR": 76923300, + "CD": 70916439, + "TH": 67089500, + "FR": 64768389, + "GB": 62348447, + "IT": 60340328, + "MM": 53414374, + "ZA": 49000000, + "KR": 48422644, + "ES": 46505963, + "UA": 45415596, + "CO": 44205293, + "TZ": 41892895, + "AR": 41343201, + "KE": 40046566, + "PL": 38500000, + "SD": 35000000, + "DZ": 34586184, + "CA": 33679000, + "UG": 33398682, + "MA": 31627428, + "PE": 29907003, + "IQ": 29671605, + "AF": 29121286, + "NP": 28951852, + "MY": 28274729, + "UZ": 27865738, + "VE": 27223228, + "SA": 25731776, + "GH": 24339838, + "YE": 23495361, + "KP": 22912177, + "TW": 22894384, + "SY": 22198110, + "MZ": 22061451, + "RO": 21959278, + "AU": 21515754, + "LK": 21513990, + "MG": 21281844, + "CI": 21058798, + "CM": 19294149, + "CL": 16746491, + "NL": 16645000, + "BF": 16241811, + "NE": 15878271, + "MW": 15447500, + "KZ": 15340000, + "EC": 14790608, + "KH": 14453680, + "ML": 13796354, + "GT": 13550440, + "ZM": 13460305, + "AO": 13068161, + "SN": 12323252, + "ZW": 11651858, + "CU": 11423000, + "RW": 11055976, + "GR": 11000000, + "CS": 10829175, + "PT": 10676000, + "TN": 10589025, + "TD": 10543464, + "CZ": 10476000, + "BE": 10403000, + "GN": 10324025, + "SO": 10112453, + "BO": 9947418, + "HU": 9930000, + "BI": 9863117, + "DO": 9823821, + "BY": 9685000, + "HT": 9648924, + "BJ": 9056010, + "SE": 9045000, + "AZ": 8303512, + "SS": 8260490, + "AT": 8205000, + "HN": 7989415, + "CH": 7581000, + "TJ": 7487489, + "IL": 7353985, + "RS": 7344847, + "BG": 7148785, + "HK": 6898686, + "TG": 6587239, + "LY": 6461454, + "JO": 6407085, + "PY": 6375830, + "LA": 6368162, + "PG": 6064515, + "SV": 6052064, + "NI": 5995928, + "ER": 5792984, + "KG": 5508626, + "DK": 5484000, + "SK": 5455000, + "SL": 5245695, + "FI": 5244000, + "NO": 5009150, + "AE": 4975593, + "TM": 4940916, + "CF": 4844927, + "SG": 4701069, + "GE": 4630000, + "IE": 4622917, + "BA": 4590000, + "CR": 4516220, + "HR": 4491000, + "MD": 4324000, + "NZ": 4252277, + "LB": 4125247, + "PR": 3916632, + "PS": 3800000, + "LR": 3685076, + "LT": 3565000, + "UY": 3477000, + "PA": 3410676, + "MR": 3205060, + "MN": 3086918, + "CG": 3039126, + "AL": 2986952, + "AM": 2968000, + "OM": 2967717, + "JM": 2847232, + "KW": 2789132, + "LV": 2217969, + "NA": 2128471, + "MK": 2061000, + "BW": 2029307, + "SI": 2007000, + "LS": 1919552, + "XK": 1800000, + "GM": 1593256, + "GW": 1565126, + "GA": 1545255, + "SZ": 1354051, + "MU": 1294104, + "EE": 1291170, + "TT": 1228691, + "TL": 1154625, + "CY": 1102677, + "GQ": 1014999, + "FJ": 875983, + "QA": 840926, + "RE": 776948, + "KM": 773407, + "GY": 748486, + "DJ": 740528, + "BH": 738004, + "BT": 699847, + "ME": 666730, + "SB": 559198, + "CV": 508659, + "LU": 497538, + "SR": 492829, + "MO": 449198, + "GP": 443000, + "MQ": 432900, + "MT": 403000, + "MV": 395650, + "BN": 395027, + "BZ": 314522, + "IS": 308910, + "BS": 301790, + "BB": 285653, + "EH": 273008, + "PF": 270485, + "VU": 221552, + "NC": 216494, + "GF": 195506, + "WS": 192001, + "ST": 175808, + "LC": 160922, + "GU": 159358, + "YT": 159042, + "CW": 141766, + "AN": 136197, + "TO": 122580, + "VI": 108708, + "GD": 107818, + "FM": 107708, + "VC": 104217, + "KI": 92533, + "JE": 90812, + "SC": 88340, + "AG": 86754, + "AD": 84000, + "IM": 75049, + "DM": 72813, + "AW": 71566, + "MH": 65859, + "BM": 65365, + "GG": 65228, + "AS": 57881, + "GL": 56375, + "MP": 53883, + "KN": 49898, + "FO": 48228, + "KY": 44270, + "SX": 37429, + "MF": 35925, + "LI": 35000, + "MC": 32965, + "SM": 31477, + "GI": 27884, + "AX": 26711, + "VG": 21730, + "CK": 21388, + "TC": 20556, + "PW": 19907, + "BQ": 18012, + "WF": 16025, + "AI": 13254, + "TV": 10472, + "NR": 10065, + "MS": 9341, + "BL": 8450, + "SH": 7460, + "PM": 7012, + "IO": 4000, + "FK": 2638, + "SJ": 2550, + "NU": 2166, + "NF": 1828, + "CX": 1500, + "TK": 1466, + "VA": 921, + "CC": 628, + "TF": 140, + "PN": 46, + "GS": 30 +} diff --git a/scripts/generate/logs/samples/weighted_list.js b/scripts/generate/logs/samples/weighted_list.js index ca8cd29fd..2babedba3 100644 --- a/scripts/generate/logs/samples/weighted_list.js +++ b/scripts/generate/logs/samples/weighted_list.js @@ -8,8 +8,11 @@ module.exports = WeightedList; var _ = require('../../../../src/lib/utils'); function WeightedList(list) { - WeightedList.callSuper(this, arguments); + Array.call(this); + _.forEach(list, _.bindKey(this, 'push')); + + console.log(this); } _.inherits(WeightedList, Array); diff --git a/scripts/generate/yaml_tests/index.js b/scripts/generate/yaml_tests/index.js index 9bd88996a..9e7907d8b 100644 --- a/scripts/generate/yaml_tests/index.js +++ b/scripts/generate/yaml_tests/index.js @@ -32,7 +32,7 @@ function download() { restSpecUpdated(function (err, updated) { - if (process.env.FORCE_GEN || process.env.npm_config_force || err || updated) { + if (err || updated) { download(); } }); diff --git a/scripts/rest_spec_updated.js b/scripts/rest_spec_updated.js index 0f615f662..c71c73cd5 100644 --- a/scripts/rest_spec_updated.js +++ b/scripts/rest_spec_updated.js @@ -7,6 +7,7 @@ var request = { } }; var fs = require('fs'); +var _ = require('lodash'); var lastRestSpecUpdateFile = __dirname + '/last_rest_spec_update.sha'; var lastRestSpecUpdate; @@ -16,46 +17,61 @@ if (fs.existsSync(lastRestSpecUpdateFile)) { lastRestSpecUpdate = fs.readFileSync(lastRestSpecUpdateFile, 'utf8'); } -var req = https.get(request, function (incoming) { - if (incoming.statusCode !== 200) { - req.abort(); - console.error('request for last commit failed', incoming.statusCode, incoming.headers); - return; - } +var req = null; +var force = false; - var body = ''; +if (process.env.npm_config_force || + process.env.FORCE_GEN || + _.contains(process.argv, '-f') || + _.contains(process.argv, '--force') +) { + force = true; +} - incoming.on('data', onData); - incoming.on('end', onEnd); - - function onData(chunk) { - body += chunk; - } - - function onEnd() { - incoming.removeListener('data', onData); - incoming.removeListener('end', onEnd); - var _req = req; - req = null; - - var resp; - try { - resp = JSON.parse(body); - } catch (e) { - console.log('unable to parse response from github'); - _req.emit('ready'); +if (force) { + updated = true; +} else { + req = https.get(request, function (incoming) { + if (incoming.statusCode !== 200) { + req.abort(); + console.error('request for last commit failed', incoming.statusCode, incoming.headers); return; } - if (lastRestSpecUpdate === resp.sha) { - updated = false; - } else { - updated = true; - fs.writeFileSync(lastRestSpecUpdateFile, resp.sha); + var body = ''; + + incoming.on('data', onData); + incoming.on('end', onEnd); + + function onData(chunk) { + body += chunk; } - _req.emit('ready'); - } -}); + + function onEnd() { + incoming.removeListener('data', onData); + incoming.removeListener('end', onEnd); + var _req = req; + req = null; + + var resp; + try { + resp = JSON.parse(body); + } catch (e) { + console.log('unable to parse response from github'); + _req.emit('ready'); + return; + } + + if (lastRestSpecUpdate === resp.sha) { + updated = false; + } else { + updated = true; + fs.writeFileSync(lastRestSpecUpdateFile, resp.sha); + } + _req.emit('ready'); + } + }); +} module.exports = function (cb) { function done() { diff --git a/scripts/run_browser_integration_suite/index.js b/scripts/run_browser_integration_suite/index.js index cbb2159d2..34943202f 100644 --- a/scripts/run_browser_integration_suite/index.js +++ b/scripts/run_browser_integration_suite/index.js @@ -5,69 +5,84 @@ var open = require('open'); var fs = require('fs'); var path = require('path'); var async = require('async'); +var chalk = require('chalk'); var yamlTestSourceFile = path.join(__dirname, '../../test/integration/yaml_suite/index.js'); -var yamlTestBundleFile = path.join(__dirname, '../../test/browser_integration/yaml_tests.js'); +var yamlTestBundleFile = path.join(__dirname, '../../test/integration/browser_yaml_suite/yaml_tests.js'); var clientEntryFile = path.join(__dirname, '../../src/elasticsearch.js'); -var browsers = _.transform({ +var browserAppNames = _.transform({ safari: { darwin: 'Safari' }, chrome: { darwin: 'Google Chrome', win32: 'Google Chrome', - executable: 'google-chrome' + linux: 'google-chrome' }, chromium: { - - executable: 'chromium-browser', + linux: 'chromium-browser', }, firefox: { darwin: 'Firefox', win32: 'Firefox', - executable: 'firefox' + linux: 'firefox' }, opera: { darwin: 'Opera', win32: 'Opera', - executable: 'opera' + linux: 'opera' } -}, function (browsers, config, name) { +}, function (browserAppNames, config, name) { if (config[process.platform]) { - browsers[name] = config[process.platform]; + browserAppNames[name] = config[process.platform]; return; } - if (process.platform !== 'darwin' && process.platform !== 'win32' && config.executable) { - browsers[name] = config.executable; + if (process.platform !== 'darwin' && process.platform !== 'win32' && config.linux) { + browserAppNames[name] = config.executable; return; } }, {}); var argv = require('optimist') - .default('browser', 'chrome') - .default('force_gen', false) - .boolean('force_gen') - .alias('f', 'force_gen') - .default('host', 'localhost') - .default('port', 9200) + .default({ + browsers: '*', + forceGen: false, + host: 'localhost', + port: 9200 + }) + .boolean('forceGen') + .alias({ + f: 'forceGen', + b: 'browsers', + h: 'host', + p: 'port' + }) .argv; -var browserAppName; +server.browsers = []; + +if (argv.browsers === '*') { + server.browsers = _.keys(browserAppNames); +} else { + argv.browsers.split(',').forEach(function (browser) { + server.browsers.push(browser); + }); +} + +var badKeys = _.difference(server.browsers, _.keys(browserAppNames)); +if (badKeys.length) { + console.error('Invalid keys: ' + badKeys.join(', ')); + process.exit(); +} else { + console.log('opening browser suite in', server.browsers); +} async.series([ - function (done) { - if (browsers.hasOwnProperty(argv.browser)) { - browserAppName = browsers[argv.browser]; - done(); - } else { - done('--browser must be set to one of ' + _.keys(browsers).join(', ') + ' on this platform'); - } - }, function (done) { fs.exists('dist', function (yes) { - if (!argv.force_gen && yes) { + if (!argv.forceGen && yes) { done(); return; } @@ -82,7 +97,7 @@ async.series([ }, function (done) { fs.exists(yamlTestBundleFile, function (yes) { - if (!argv.force_gen && yes) { + if (!argv.forceGen && yes) { done(); return; } @@ -131,13 +146,32 @@ async.series([ var port = server.address().port; console.log('server listening on port', port); - open('http://localhost:' + port + '?es_hostname=' + encodeURIComponent(argv.host) + - '&es_port=' + encodeURIComponent(argv.port) + - '&browser=' + encodeURIComponent(argv.browser), browserAppName); + async.eachSeries(_.clone(server.browsers), function (browser, done) { + open('http://localhost:' + port + + '?es_hostname=' + encodeURIComponent(argv.host) + + '&es_port=' + encodeURIComponent(argv.port) + + '&browser=' + encodeURIComponent(browser), browserAppNames[browser]); + + server.once('browser complete', function () { + done(); + }); + }); }); - server.on('tests done', function (success) { - console.log('test completed', success ? 'successfully' : 'but failed'); + server.on('tests done', function (report) { + var reports = []; + var success = true; + _.each(report, function (testSucceeded, browser) { + var msg = browser + ':' + (success ? '✔︎' : '⚑'); + if (testSucceeded) { + msg = chalk.green(msg); + } else { + msg = chalk.red(msg); + success = false; + } + reports.push(' - ' + msg); + }); + console.log('test completed!\n', reports.join('\n')); process.exit(success ? 0 : 1); }); } diff --git a/scripts/run_browser_integration_suite/server.js b/scripts/run_browser_integration_suite/server.js index 8a3a93055..f52bde59e 100644 --- a/scripts/run_browser_integration_suite/server.js +++ b/scripts/run_browser_integration_suite/server.js @@ -5,6 +5,7 @@ var fs = require('fs'); var _ = require('lodash'); var chalk = require('chalk'); var makeJUnitXml = require('../make_j_unit_xml'); +var docRoot = path.join(__dirname, '../../test/integration/browser_yaml_suite'); chalk.enabled = true; var middleware = []; @@ -17,7 +18,7 @@ var server = http.createServer(function (req, resp) { var parsedUrl = url.parse(req.url, true); req.uri = parsedUrl.pathname; req.query = parsedUrl.query; - req.filename = path.join(__dirname, '../../test/browser_integration/', req.uri); + req.filename = path.join(docRoot, req.uri); var end = resp.end; resp.end = function () { @@ -39,6 +40,11 @@ var server = http.createServer(function (req, resp) { next(); }); +server.browsers = [ + // browsers will go here, and will be removed once they call tests-complete + // once gone, we will emit "tests done" +]; + function rand(length) { var str = ''; while (str.length < length) { @@ -50,7 +56,7 @@ function rand(length) { function collectTestResults(req, resp) { var body = ''; var browser = req.query.browser; - var logFilename = path.join(__dirname, '../../test-output-' + browser + '.xml'); + var logFilename = 'test-output-' + browser + '.xml'; req.on('data', function (chunk) { body += chunk; @@ -79,15 +85,33 @@ function collectTestResults(req, resp) { if (err) { console.log('unable to save test-output to', err.message); console.trace(); - server.emit('tests done', false); + browserComplete(browser); } else { console.log('test output written to', logFilename); - server.emit('tests done', !testDetails.stats.failures); + browserComplete(browser, true); } }); }); } +var report = {}; + +function browserComplete(browser, success) { + var i = server.browsers.indexOf(browser); + report[browser] = success; + server.emit('browser complete', browser, success); + if (i >= 0) { + server.browsers.splice(i, 1); + if (server.browsers.length) { + console.log('waiting for', server.browsers.length, 'browsers'); + } else { + server.emit('tests done', report); + } + } else { + console.error('invalid browser', browser); + } +} + middleware.push(function (req, resp, next) { // resolve filenames @@ -120,7 +144,7 @@ middleware.push(function (req, resp, next) { resp.end(); } else { if (stats.isDirectory()) { - req.filename = path.join(req.filename, '../../test/browser_integration/index.html'); + req.filename = path.join(docRoot, 'index.html'); } next(); } @@ -176,7 +200,7 @@ middleware.push(function (req, resp) { es_hostname: 'localhost', es_port: 9200, browser: 'unknown', - ts: 'no'//rand(5) + ts: rand(5) }))); } else { resp.end(data); diff --git a/scripts/run_tests.js b/scripts/run_tests.js index dc6f0ba8a..5cdc27b92 100644 --- a/scripts/run_tests.js +++ b/scripts/run_tests.js @@ -9,13 +9,13 @@ var argv = require('optimist') ].join('\n')) .default({ server: true, - browser: true, unit: true, integration: false, host: 'localhost', port: 9200, 'xml-output': true, - 'check-upstream': false + 'check-upstream': false, + 'browsers': '*' }) .describe({ host: 'hostname for elasticsearch instance used in integration tests', @@ -24,7 +24,7 @@ var argv = require('optimist') .alias({ u: 'unit', i: 'integration', - b: 'browser', + b: 'browsers', s: 'server', x: 'xml-output' }); @@ -46,7 +46,7 @@ var commands = []; if (argv['just-browser']) { argv.server = false; - argv.browser = true; + argv.browsers = '*'; } if (argv['check-upstream']) { @@ -57,7 +57,7 @@ if (argv.unit) { if (argv.server) { commands.push(['mocha', 'test/unit/test_*.js', '--require=should']); } - if (argv.browser) { + if (argv.browsers) { commands.push(['testling', '.']); } } @@ -74,8 +74,13 @@ if (argv.integration) { '--port', argv.port ].filter(Boolean)); } - if (argv.browser) { - commands.push(['node', 'scripts/run_browser_integration_suite/index.js']); + if (argv.browsers) { + commands.push([ + 'node', + 'scripts/run_browser_integration_suite/index.js', + '--browsers', + argv.browsers + ]); } } diff --git a/src/elasticsearch.js b/src/elasticsearch.js index 8f2a39e20..4eda23b14 100644 --- a/src/elasticsearch.js +++ b/src/elasticsearch.js @@ -1,8 +1,9 @@ var es = { Client: require('./lib/client'), - errors: require('./lib/errors'), ConnectionPool: require('./lib/connection_pool'), - Transport: require('./lib/transport') + Transport: require('./lib/transport'), + + errors: require('./lib/errors') }; module.exports = es; diff --git a/src/lib/api.js b/src/lib/api.js index 5ba0e113a..6575ee0ff 100644 --- a/src/lib/api.js +++ b/src/lib/api.js @@ -13,7 +13,7 @@ api._namespaces = ['cluster', 'indices']; * @param {Boolean} params.refresh - Refresh the index after performing the operation * @param {String} [params.replication=sync] - Explicitely set the replication type * @param {String} params.type - Default document type for items which don't provide one - * @param {Date or Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.timeout - Explicit operation timeout * @param {String} params.index - Default index for items which don't provide one */ api.bulk = ca({ @@ -77,7 +77,7 @@ api.bulk = ca({ * Perform a [clearScroll](http://www.elasticsearch.org/guide/reference/api/search/scroll/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.scrollId - A comma-separated list of scroll IDs to clear + * @param {String, String[], Boolean} params.scrollId - A comma-separated list of scroll IDs to clear */ api.clearScroll = ca({ url: { @@ -115,8 +115,8 @@ api.cluster.prototype.getSettings = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.level=cluster] - Specify the level of detail for returned information * @param {Boolean} params.local - Return local information, do not retrieve the state from master node (default: false) - * @param {Date or Number} params.masterTimeout - Explicit operation timeout for connection to master node - * @param {Date or Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {Date, Number} params.timeout - Explicit operation timeout * @param {Number} params.waitForActiveShards - Wait until the specified number of shards is active * @param {String} params.waitForNodes - Wait until the specified number of nodes is available * @param {Number} params.waitForRelocatingShards - Wait until the specified number of relocating shards is finished @@ -187,11 +187,11 @@ api.cluster.prototype.health = ca({ * Perform a [cluster.nodeHotThreads](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-hot-threads/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.interval - The interval for the second sampling of threads + * @param {Date, Number} params.interval - The interval for the second sampling of threads * @param {Number} params.snapshots - Number of samples of thread stacktrace (default: 10) * @param {Number} params.threads - Specify the number of threads to provide information for (default: 3) * @param {String} params.type - The type to sample (default: cpu) - * @param {String or String[] or 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.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 */ api.cluster.prototype.nodeHotThreads = ca({ params: { @@ -243,9 +243,9 @@ api.cluster.prototype.nodeHotThreads = ca({ * @param {Boolean} params.process - Return information about the Elasticsearch process * @param {Boolean} params.settings - Return information about node settings * @param {Boolean} params.threadPool - Return information about the thread pool - * @param {Date or Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.timeout - Explicit operation timeout * @param {Boolean} params.transport - Return information about transport - * @param {String or String[] or 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.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 */ api.cluster.prototype.nodeInfo = ca({ params: { @@ -307,9 +307,9 @@ api.cluster.prototype.nodeInfo = ca({ * Perform a [cluster.nodeShutdown](http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.delay - Set the delay for the operation (default: 1s) + * @param {Date, Number} params.delay - Set the delay for the operation (default: 1s) * @param {Boolean} params.exit - Exit the JVM as well (default: true) - * @param {String or String[] or Boolean} params.nodeId - A comma-separated list of node IDs or names to perform the operation on; use `_local` to perform the operation on the node you're connected to, leave empty to perform the operation on all nodes + * @param {String, String[], Boolean} params.nodeId - A comma-separated list of node IDs or names to perform the operation on; use `_local` to perform the operation on the node you're connected to, leave empty to perform the operation on all nodes */ api.cluster.prototype.nodeShutdown = ca({ params: { @@ -343,7 +343,7 @@ api.cluster.prototype.nodeShutdown = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {Boolean} params.all - Return all available information * @param {Boolean} params.clear - Reset the default level of detail - * @param {String or String[] or Boolean} params.fields - A comma-separated list of fields to return detailed information for, when returning the `indices` metric family (supports wildcards) + * @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return detailed information for, when returning the `indices` metric family (supports wildcards) * @param {Boolean} params.fs - Return information about the filesystem * @param {Boolean} params.http - Return information about HTTP * @param {Boolean} params.indices - Return information about indices @@ -355,7 +355,7 @@ api.cluster.prototype.nodeShutdown = ca({ * @param {Boolean} params.transport - Return information about transport * @param {String} params.metricFamily - Limit the information returned to a certain metric family * @param {String} params.metric - Limit the information returned for `indices` family to a specific metric - * @param {String or String[] or 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.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 */ api.cluster.prototype.nodeStats = ca({ params: { @@ -457,12 +457,12 @@ api.cluster.prototype.reroute = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {Boolean} params.filterBlocks - Do not return information about blocks * @param {Boolean} params.filterIndexTemplates - Do not return information about index templates - * @param {String or String[] or Boolean} params.filterIndices - Limit returned metadata information to specific indices + * @param {String, String[], Boolean} params.filterIndices - Limit returned metadata information to specific indices * @param {Boolean} params.filterMetadata - Do not return information about indices metadata * @param {Boolean} params.filterNodes - Do not return information about nodes * @param {Boolean} params.filterRoutingTable - Do not return information about shard allocation (`routing_table` and `routing_nodes`) * @param {Boolean} params.local - Return local information, do not retrieve the state from master node (default: false) - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master */ api.cluster.prototype.state = ca({ params: { @@ -513,8 +513,8 @@ api.cluster.prototype.state = ca({ * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {String} params.routing - Specific routing value * @param {String} params.source - The URL-encoded query definition (instead of using the request body) - * @param {String or String[] or Boolean} params.index - A comma-separated list of indices to restrict the results - * @param {String or String[] or Boolean} params.type - A comma-separated list of types to restrict the results + * @param {String, String[], Boolean} params.index - A comma-separated list of indices to restrict the results + * @param {String, String[], Boolean} params.type - A comma-separated list of types to restrict the results */ api.count = ca({ params: { @@ -578,7 +578,7 @@ api.count = ca({ * @param {Boolean} params.refresh - Refresh the index after performing the operation * @param {String} [params.replication=sync] - Specific replication type * @param {String} params.routing - Specific routing value - * @param {Date or Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.timeout - Explicit operation timeout * @param {Number} params.version - Explicit version number for concurrency control * @param {String} params.versionType - Specific version type * @param {String} params.id - The document ID @@ -659,9 +659,9 @@ api['delete'] = ca({ * @param {String} params.q - Query in the Lucene query string syntax * @param {String} params.routing - Specific routing value * @param {String} params.source - The URL-encoded query definition (instead of using the request body) - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {String or String[] or Boolean} params.index - A comma-separated list of indices to restrict the operation; use `_all` to perform the operation on all indices - * @param {String or String[] or Boolean} params.type - A comma-separated list of types to restrict the operation + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {String, String[], Boolean} params.index - A comma-separated list of indices to restrict the operation; use `_all` to perform the operation on all indices + * @param {String, String[], Boolean} params.type - A comma-separated list of types to restrict the operation */ api.deleteByQuery = ca({ params: { @@ -805,16 +805,16 @@ api.exists = ca({ * @param {String} params.analyzer - The analyzer for the query string query * @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) * @param {String} params.df - The default field for query string query (default: _all) - * @param {String or String[] or Boolean} params.fields - A comma-separated list of fields to return in the response + * @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return in the response * @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.parent - The ID of the parent document * @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} params.routing - Specific routing value - * @param {String or String[] or Boolean} params.source - True or false to return the _source field or not, or a list of fields to return - * @param {String or String[] or Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field - * @param {String or String[] or Boolean} params.sourceInclude - A list of fields to extract and return from the _source field + * @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 {String} params.id - The document ID * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document @@ -898,15 +898,15 @@ api.explain = ca({ * Perform a [get](http://elasticsearch.org/guide/reference/api/get/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.fields - A comma-separated list of fields to return in the response + * @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return in the response * @param {String} params.parent - The ID of the parent document * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {Boolean} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {Boolean} params.refresh - Refresh the shard containing the document before performing the operation * @param {String} params.routing - Specific routing value - * @param {String or String[] or Boolean} params.source - True or false to return the _source field or not, or a list of fields to return - * @param {String or String[] or Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field - * @param {String or String[] or Boolean} params.sourceInclude - A list of fields to extract and return from the _source field + * @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 {String} params.id - The document ID * @param {String} params.index - The name of the index * @param {String} [params.type=_all] - The type of the document (use `_all` to fetch the first document matching the ID across all types) @@ -969,8 +969,8 @@ api.get = ca({ * Perform a [getSource](http://elasticsearch.org/guide/reference/api/get/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.exclude - A list of fields to exclude from the returned _source field - * @param {String or String[] or Boolean} params.include - A list of fields to extract and return from the _source field + * @param {String, String[], Boolean} params.exclude - A list of fields to exclude from the returned _source field + * @param {String, String[], Boolean} params.include - A list of fields to extract and return from the _source field * @param {String} params.parent - The ID of the parent document * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {Boolean} params.realtime - Specify whether to perform the operation in realtime or search mode @@ -1036,8 +1036,8 @@ api.getSource = ca({ * @param {Boolean} params.refresh - Refresh the index after performing the operation * @param {String} [params.replication=sync] - Specific replication type * @param {String} params.routing - Specific routing value - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.timestamp - Explicit timestamp for the document + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.timestamp - Explicit timestamp for the document * @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 @@ -1146,7 +1146,7 @@ api.indices = function IndicesNS(transport) { * @param {Object} params - An object with parameters used to carry out this action * @param {String} params.analyzer - The name of the analyzer to use * @param {String} params.field - Use the analyzer configured for this field (instead of passing the analyzer name) - * @param {String or String[] or Boolean} params.filters - A comma-separated list of filters to use for the analysis + * @param {String, String[], Boolean} params.filters - A comma-separated list of filters to use for the analysis * @param {String} params.index - The name of the index to scope the operation * @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} params.text - The text on which the analysis should be performed (when request body is not used) @@ -1209,14 +1209,14 @@ api.indices.prototype.analyze = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {Boolean} params.fieldData - Clear field data * @param {Boolean} params.fielddata - Clear field data - * @param {String or String[] or Boolean} params.fields - A comma-separated list of fields to clear when using the `field_data` parameter (default: all) + * @param {String, String[], Boolean} params.fields - A comma-separated list of fields to clear when using the `field_data` parameter (default: all) * @param {Boolean} params.filter - Clear filter caches * @param {Boolean} params.filterCache - Clear filter caches * @param {Boolean} params.filterKeys - A comma-separated list of keys to clear when using the `filter_cache` parameter (default: all) * @param {Boolean} params.id - Clear ID caches for parent/child * @param {Boolean} params.idCache - Clear ID caches for parent/child * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {String or String[] or Boolean} params.index - A comma-separated list of index name to limit the operation + * @param {String, String[], Boolean} params.index - A comma-separated list of index name to limit the operation * @param {Boolean} params.recycler - Clear the recycler cache */ api.indices.prototype.clearCache = ca({ @@ -1286,8 +1286,8 @@ api.indices.prototype.clearCache = ca({ * Perform a [indices.close](http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master * @param {String} params.index - The name of the index */ api.indices.prototype.close = ca({ @@ -1317,8 +1317,8 @@ api.indices.prototype.close = ca({ * Perform a [indices.create](http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master * @param {String} params.index - The name of the index */ api.indices.prototype.create = ca({ @@ -1348,9 +1348,9 @@ api.indices.prototype.create = ca({ * Perform a [indices.delete](http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-index/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master - * @param {String or String[] or Boolean} params.index - A comma-separated list of indices to delete; use `_all` or empty string to delete all indices + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master + * @param {String, String[], Boolean} params.index - A comma-separated list of indices to delete; use `_all` or empty string to delete all indices */ api.indices.prototype['delete'] = ca({ params: { @@ -1383,8 +1383,8 @@ api.indices.prototype['delete'] = ca({ * Perform a [indices.deleteAlias](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit timestamp for the document - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @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 */ @@ -1418,8 +1418,8 @@ api.indices.prototype.deleteAlias = ca({ * Perform a [indices.deleteMapping](http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` for all indices + * @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 */ api.indices.prototype.deleteMapping = ca({ @@ -1449,8 +1449,8 @@ api.indices.prototype.deleteMapping = ca({ * Perform a [indices.deleteTemplate](http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master * @param {String} params.name - The name of the template */ api.indices.prototype.deleteTemplate = ca({ @@ -1480,10 +1480,10 @@ api.indices.prototype.deleteTemplate = ca({ * Perform a [indices.deleteWarmer](http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master - * @param {String or String[] or 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 {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 or String[] or 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.type - A comma-separated list of document types to register warmer for; use `_all` or empty string to perform the operation on all types */ api.indices.prototype.deleteWarmer = ca({ params: { @@ -1535,7 +1535,7 @@ api.indices.prototype.deleteWarmer = ca({ * Perform a [indices.exists](http://www.elasticsearch.org/guide/reference/api/admin-indices-indices-exists/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.index - A comma-separated list of indices to check + * @param {String, String[], Boolean} params.index - A comma-separated list of indices to check */ api.indices.prototype.exists = ca({ url: { @@ -1557,8 +1557,8 @@ api.indices.prototype.exists = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to filter aliases - * @param {String or String[] or Boolean} params.name - A comma-separated list of alias names to return + * @param {String, String[], Boolean} params.index - A comma-separated list of index names to filter aliases + * @param {String, String[], Boolean} params.name - A comma-separated list of alias names to return */ api.indices.prototype.existsAlias = ca({ params: { @@ -1603,8 +1603,8 @@ api.indices.prototype.existsAlias = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` to check the types across all indices - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types to check + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` to check the types across all indices + * @param {String, String[], Boolean} params.type - A comma-separated list of document types to check */ api.indices.prototype.existsType = ca({ params: { @@ -1643,7 +1643,7 @@ api.indices.prototype.existsType = ca({ * @param {Boolean} params.full - TODO: ? * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones * @param {Boolean} params.refresh - Refresh the index after performing the operation - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` or empty string for all indices + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string for all indices */ api.indices.prototype.flush = ca({ params: { @@ -1688,8 +1688,8 @@ api.indices.prototype.flush = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to filter aliases - * @param {String or String[] or Boolean} params.name - A comma-separated list of alias names to return + * @param {String, String[], Boolean} params.index - A comma-separated list of index names to filter aliases + * @param {String, String[], Boolean} params.name - A comma-separated list of alias names to return */ api.indices.prototype.getAlias = ca({ params: { @@ -1731,8 +1731,8 @@ api.indices.prototype.getAlias = ca({ * Perform a [indices.getAliases](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to filter aliases + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {String, String[], Boolean} params.index - A comma-separated list of index names to filter aliases */ api.indices.prototype.getAliases = ca({ params: { @@ -1761,9 +1761,9 @@ api.indices.prototype.getAliases = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {Boolean} params.includeDefaults - Whether the default mapping values should be returned as well - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types - * @param {String or String[] or Boolean} params.field - A comma-separated list of fields + * @param {String, String[], Boolean} params.index - A comma-separated list of index names + * @param {String, String[], Boolean} params.type - A comma-separated list of document types + * @param {String, String[], Boolean} params.field - A comma-separated list of fields */ api.indices.prototype.getFieldMapping = ca({ params: { @@ -1814,8 +1814,8 @@ api.indices.prototype.getFieldMapping = ca({ * Perform a [indices.getMapping](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types + * @param {String, String[], Boolean} params.index - A comma-separated list of index names + * @param {String, String[], Boolean} params.type - A comma-separated list of document types */ api.indices.prototype.getMapping = ca({ urls: [ @@ -1849,7 +1849,7 @@ api.indices.prototype.getMapping = ca({ * Perform a [indices.getSettings](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-settings/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; 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; use `_all` or empty string to perform the operation on all indices */ api.indices.prototype.getSettings = ca({ urls: [ @@ -1895,9 +1895,9 @@ api.indices.prototype.getTemplate = ca({ * Perform a [indices.getWarmer](http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to restrict the operation; use `_all` to perform the operation on all indices + * @param {String, String[], Boolean} params.index - A comma-separated list of index names to restrict the operation; use `_all` to perform the operation on all indices * @param {String} params.name - The name of the warmer (supports wildcards); leave empty to get all warmers - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types + * @param {String, String[], Boolean} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types */ api.indices.prototype.getWarmer = ca({ urls: [ @@ -1942,8 +1942,8 @@ api.indices.prototype.getWarmer = ca({ * Perform a [indices.open](http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master * @param {String} params.index - The name of the index */ api.indices.prototype.open = ca({ @@ -1977,10 +1977,10 @@ api.indices.prototype.open = ca({ * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones * @param {Number} params.maxNumSegments - The number of segments the index should be merged into (default: dynamic) * @param {Boolean} params.onlyExpungeDeletes - Specify whether the operation should only expunge deleted documents - * @param {*} params.operationThreading - TODO: ? + * @param {Anything} params.operationThreading - TODO: ? * @param {Boolean} params.refresh - Specify whether the index should be refreshed after performing the operation (default: true) * @param {Boolean} params.waitForMerge - Specify whether the request should block until the merge process is finished (default: true) - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; 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; use `_all` or empty string to perform the operation on all indices */ api.indices.prototype.optimize = ca({ params: { @@ -2036,8 +2036,8 @@ api.indices.prototype.optimize = ca({ * Perform a [indices.putAlias](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Explicit timestamp for the document - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @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 created or updated */ @@ -2092,9 +2092,9 @@ api.indices.prototype.putAlias = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {Boolean} params.ignoreConflicts - Specify whether to ignore conflicts while updating the mapping (default: false) - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` to perform the operation on all indices + * @param {Date, Number} params.timeout - Explicit operation timeout + * @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` to perform the operation on all indices * @param {String} params.type - The name of the document type */ api.indices.prototype.putMapping = ca({ @@ -2131,8 +2131,8 @@ api.indices.prototype.putMapping = ca({ * Perform a [indices.putSettings](http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @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` or empty string to perform the operation on all indices */ api.indices.prototype.putSettings = ca({ params: { @@ -2163,8 +2163,8 @@ api.indices.prototype.putSettings = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {Number} params.order - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master * @param {String} params.name - The name of the template */ api.indices.prototype.putTemplate = ca({ @@ -2197,10 +2197,10 @@ api.indices.prototype.putTemplate = ca({ * Perform a [indices.putWarmer](http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master - * @param {String or String[] or 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 {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 the warmer for; use `_all` or empty string to perform the operation on all indices * @param {String} params.name - The name of the warmer - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types to register the warmer for; leave empty to perform the operation on all types + * @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 */ api.indices.prototype.putWarmer = ca({ params: { @@ -2245,8 +2245,8 @@ api.indices.prototype.putWarmer = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {*} params.operationThreading - TODO: ? - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {Anything} params.operationThreading - TODO: ? + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices */ api.indices.prototype.refresh = ca({ params: { @@ -2285,8 +2285,8 @@ api.indices.prototype.refresh = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {*} params.operationThreading - TODO: ? - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {Anything} params.operationThreading - TODO: ? + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices */ api.indices.prototype.segments = ca({ params: { @@ -2324,7 +2324,7 @@ api.indices.prototype.segments = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` or empty string for all indices + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string for all indices */ api.indices.prototype.snapshotIndex = ca({ params: { @@ -2362,11 +2362,11 @@ api.indices.prototype.snapshotIndex = ca({ * @param {Boolean} params.all - Return all available information * @param {Boolean} params.clear - Reset the default level of detail * @param {Boolean} params.completion - Return information about completion suggester stats - * @param {String or String[] or Boolean} params.completionFields - A comma-separated list of fields for `completion` metric (supports wildcards) + * @param {String, String[], Boolean} params.completionFields - A comma-separated list of fields for `completion` metric (supports wildcards) * @param {Boolean} params.docs - Return information about indexed and deleted documents * @param {Boolean} params.fielddata - Return information about field data - * @param {String or String[] or Boolean} params.fielddataFields - A comma-separated list of fields for `fielddata` metric (supports wildcards) - * @param {String or String[] or Boolean} params.fields - A comma-separated list of fields to return detailed information for, when returning the `search` statistics + * @param {String, String[], Boolean} params.fielddataFields - A comma-separated list of fields for `fielddata` metric (supports wildcards) + * @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return detailed information for, when returning the `search` statistics * @param {Boolean} params.filterCache - Return information about filter cache * @param {Boolean} params.flush - Return information about flush operations * @param {Boolean} params.get - Return information about get operations @@ -2379,10 +2379,10 @@ api.indices.prototype.snapshotIndex = ca({ * @param {Boolean} params.search - Return information about search operations; use the `groups` parameter to include information for specific search groups * @param {Boolean} params.store - Return information about the size of the index * @param {Boolean} params.warmer - Return information about warmers - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * @param {String or String[] or Boolean} params.indexingTypes - A comma-separated list of document types to include in the `indexing` statistics + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {String, String[], Boolean} params.indexingTypes - A comma-separated list of document types to include in the `indexing` statistics * @param {String} params.metricFamily - Limit the information returned to a specific metric - * @param {String or String[] or Boolean} params.searchGroups - A comma-separated list of search groups to include in the `search` statistics + * @param {String, String[], Boolean} params.searchGroups - A comma-separated list of search groups to include in the `search` statistics */ api.indices.prototype.stats = ca({ params: { @@ -2478,10 +2478,10 @@ api.indices.prototype.stats = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {*} params.operationThreading - TODO: ? + * @param {Anything} params.operationThreading - TODO: ? * @param {Boolean} params.recovery - Return information about shard recovery * @param {Boolean} params.snapshot - TODO: ? - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names; 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; use `_all` or empty string to perform the operation on all indices */ api.indices.prototype.status = ca({ params: { @@ -2524,9 +2524,9 @@ api.indices.prototype.status = ca({ * Perform a [indices.updateAliases](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {Date or Number} params.timeout - Request timeout - * @param {Date or Number} params.masterTimeout - Specify timeout for connection to master - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to filter aliases + * @param {Date, Number} params.timeout - Request timeout + * @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 filter aliases */ api.indices.prototype.updateAliases = ca({ params: { @@ -2551,11 +2551,11 @@ api.indices.prototype.updateAliases = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {Boolean} params.explain - Return detailed information about the error * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {*} params.operationThreading - TODO: ? + * @param {Anything} params.operationThreading - TODO: ? * @param {String} params.source - The URL-encoded query definition (instead of using the request body) * @param {String} params.q - Query in the Lucene query string syntax - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types + * @param {String, String[], Boolean} params.index - A comma-separated list of index names to restrict the operation; 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 restrict the operation; leave empty to perform the operation on all types */ api.indices.prototype.validateQuery = ca({ params: { @@ -2625,13 +2625,13 @@ api.info = ca({ * Perform a [mget](http://elasticsearch.org/guide/reference/api/multi-get/) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {String or String[] or Boolean} params.fields - A comma-separated list of fields to return in the response + * @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return in the response * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {Boolean} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {Boolean} params.refresh - Refresh the shard containing the document before performing the operation - * @param {String or String[] or Boolean} params.source - True or false to return the _source field or not, or a list of fields to return - * @param {String or String[] or Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field - * @param {String or String[] or Boolean} params.sourceInclude - A list of fields to extract and return from the _source field + * @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 {String} params.index - The name of the index * @param {String} params.type - The type of the document */ @@ -2701,18 +2701,18 @@ api.mget = ca({ * @param {Number} params.minDocFreq - The word occurrence frequency as count: words with lower occurrence in the corpus will be ignored * @param {Number} params.minTermFreq - The term frequency as percent: terms with lower occurence in the source document will be ignored * @param {Number} params.minWordLen - The minimum length of the word: shorter words will be ignored - * @param {String or String[] or Boolean} params.mltFields - Specific fields to perform the query against + * @param {String, String[], Boolean} params.mltFields - Specific fields to perform the query against * @param {Number} params.percentTermsToMatch - How many terms have to match in order to consider the document a match (default: 0.3) * @param {String} params.routing - Specific routing value * @param {Number} params.searchFrom - The offset from which to return results - * @param {String or String[] or Boolean} params.searchIndices - A comma-separated list of indices to perform the query against (default: the index containing the document) + * @param {String, String[], Boolean} params.searchIndices - A comma-separated list of indices to perform the query against (default: the index containing the document) * @param {String} params.searchQueryHint - The search query hint * @param {String} params.searchScroll - A scroll search request definition * @param {Number} params.searchSize - The number of documents to return (default: 10) * @param {String} params.searchSource - A specific search request definition (instead of using the request body) * @param {String} params.searchType - Specific search type (eg. `dfs_then_fetch`, `count`, etc) - * @param {String or String[] or Boolean} params.searchTypes - A comma-separated list of types to perform the query against (default: the same type as the document) - * @param {String or String[] or Boolean} params.stopWords - A list of stop words to be ignored + * @param {String, String[], Boolean} params.searchTypes - A comma-separated list of types to perform the query against (default: the same type as the document) + * @param {String, String[], Boolean} params.stopWords - A list of stop words to be ignored * @param {String} params.id - The document ID * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document (use `_all` to fetch the first document matching the ID across all types) @@ -2819,8 +2819,8 @@ api.mlt = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} params.searchType - Search operation type - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to use as default - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types to use as default + * @param {String, String[], Boolean} params.index - A comma-separated list of index names to use as default + * @param {String, String[], Boolean} params.type - A comma-separated list of document types to use as default */ api.msearch = ca({ params: { @@ -2940,31 +2940,31 @@ api.scroll = ca({ * @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 or String[] or Boolean} params.fields - A comma-separated list of fields to return 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 {Number} params.from - Starting offset (default: 0) * @param {String} [params.ignoreIndices=none] - When performed on multiple indices, allows to ignore `missing` ones - * @param {String or String[] or Boolean} params.indicesBoost - Comma-separated list of index boosts + * @param {String, String[], Boolean} params.indicesBoost - Comma-separated list of index boosts * @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 or String[] or Boolean} params.routing - A comma-separated list of specific routing values + * @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 {Number} params.size - Number of hits to return (default: 10) - * @param {String or String[] or Boolean} params.sort - A comma-separated list of : pairs - * @param {String or String[] or Boolean} params.source - True or false to return the _source field or not, or a list of fields to return - * @param {String or String[] or Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field - * @param {String or String[] or Boolean} params.sourceInclude - A list of fields to extract and return from the _source field - * @param {String or String[] or Boolean} params.stats - Specific 'tag' of the request for logging and statistical purposes + * @param {String, String[], Boolean} params.sort - A comma-separated list of : 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 {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 or Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.timeout - Explicit operation timeout * @param {Boolean} params.version - Specify whether to return document version as part of a hit - * @param {String or String[] or Boolean} [params.index=_all] - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * @param {String or String[] or Boolean} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + * @param {String, String[], Boolean} [params.index=_all] - 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.search = ca({ params: { @@ -3127,7 +3127,7 @@ api.search = ca({ * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {String} params.routing - Specific routing value * @param {String} params.source - The URL-encoded request definition (instead of using request body) - * @param {String or String[] or Boolean} params.index - A comma-separated list of index names to restrict the operation; 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 restrict the operation; use `_all` or empty string to perform the operation on all indices */ api.suggest = ca({ params: { @@ -3172,7 +3172,7 @@ api.suggest = ca({ * * @param {Object} params - An object with parameters used to carry out this action * @param {String} params.consistency - Explicit write consistency setting for the operation - * @param {String or String[] or Boolean} params.fields - A comma-separated list of fields to return in the response + * @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return in the response * @param {String} params.lang - The script language (default: mvel) * @param {String} params.parent - ID of the parent document * @param {String} params.percolate - Perform percolation during the operation; use specific registered query name, attribute, or wildcard @@ -3180,9 +3180,9 @@ api.suggest = ca({ * @param {String} [params.replication=sync] - Specific replication type * @param {Number} params.retryOnConflict - Specify how many times should the operation be retried when a conflict occurs (default: 0) * @param {String} params.routing - Specific routing value - * @param {*} params.script - The URL-encoded script definition (instead of using request body) - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.timestamp - Explicit timestamp for the document + * @param {Anything} params.script - The URL-encoded script definition (instead of using request body) + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.timestamp - Explicit timestamp for the document * @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 @@ -3281,8 +3281,8 @@ api.update = ca({ * @param {Boolean} params.refresh - Refresh the index after performing the operation * @param {String} [params.replication=sync] - Specific replication type * @param {String} params.routing - Specific routing value - * @param {Date or Number} params.timeout - Explicit operation timeout - * @param {Date or Number} params.timestamp - Explicit timestamp for the document + * @param {Date, Number} params.timeout - Explicit operation timeout + * @param {Date, Number} params.timestamp - Explicit timestamp for the document * @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 diff --git a/src/lib/client.js b/src/lib/client.js index 6d728750f..cd50c7d4f 100755 --- a/src/lib/client.js +++ b/src/lib/client.js @@ -59,7 +59,7 @@ Client.prototype.ping = ca({ url: { fmt: '/' }, - timeout: 100 + requestTimeout: 100 }); Client.prototype.close = function () { diff --git a/src/lib/client_action.js b/src/lib/client_action.js index a13f1524d..a7ffcb831 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -176,12 +176,16 @@ ClientAction.resolveUrl = resolveUrl; function exec(transport, spec, params, cb) { var request = { - method: spec.method, - timeout: spec.timeout || 10000 + method: spec.method }; var query = {}; var i; + // pass the timeout from the spec + if (spec.requestTimeout) { + request.requestTimeout = spec.requestTimeout; + } + // verify that we have the body if needed if (spec.needsBody && !params.body) { throw new TypeError('A request body is required.'); @@ -228,16 +232,16 @@ function exec(transport, spec, params, cb) { if (params.hasOwnProperty(key) && params[key] != null) { switch (key) { case 'body': - request.body = params.body; + request.body = params[key]; break; case 'ignore': - request.ignore = _.isArray(params.ignore) ? params.ignore : [params.ignore]; + request.ignore = _.isArray(params[key]) ? params[key] : [params[key]]; break; - case 'timeout': - request.timeout = params.timeout; + case 'requestTimeout': + request.requestTimeout = params[key]; break; case 'method': - request.method = _.toUpperString(params.method); + request.method = _.toUpperString(params[key]); break; default: paramSpec = spec.params[key]; diff --git a/src/lib/connection.js b/src/lib/connection.js index 284d7151e..dae8f625f 100644 --- a/src/lib/connection.js +++ b/src/lib/connection.js @@ -2,6 +2,13 @@ module.exports = ConnectionAbstract; var _ = require('./utils'); var EventEmitter = require('events').EventEmitter; +var Log = require('./log'); +var Host = require('./host'); + +var defaults = { + deadTimeout: 30000, + requestTimeout: 10000 +}; /** * Abstract class used for Connection classes @@ -9,16 +16,19 @@ var EventEmitter = require('events').EventEmitter; * @constructor */ function ConnectionAbstract(host, config) { - config = _.defaults(config || {}, { - deadTimeout: 30000 - }); EventEmitter.call(this); + + config = _.defaults(config || {}, defaults); + this.deadTimeout = config.deadTimeout; + this.requestTimeout = config.requestTimeout; this.requestCount = 0; + this.log = config.log || new Log(); + if (!host) { throw new TypeError('Missing host'); - } else if (host.makeUrl) { + } else if (host instanceof Host) { this.host = host; } else { throw new TypeError('Invalid host'); @@ -35,7 +45,7 @@ _.inherits(ConnectionAbstract, EventEmitter); * @param [params] {Object} - The parameters for the request * @param params.path {String} - The path for which you are requesting * @param params.method {String} - The HTTP method for the request (GET, HEAD, etc.) - * @param params.timeout {Integer} - The amount of time in milliseconds that this request should be allowed to run for. + * @param params.requestTimeout {Integer} - The amount of time in milliseconds that this request should be allowed to run for. * @param cb {Function} - A callback to be called once with `cb(err, responseBody, responseStatus)` */ ConnectionAbstract.prototype.request = function () { @@ -50,7 +60,7 @@ ConnectionAbstract.prototype.ping = function (cb) { return this.request({ path: '/', method: 'HEAD', - timeout: 100 + requestTimeout: 100 }, cb); }; diff --git a/src/lib/connectors/angular.js b/src/lib/connectors/angular.js index c30993a78..cc6848dbd 100644 --- a/src/lib/connectors/angular.js +++ b/src/lib/connectors/angular.js @@ -21,7 +21,7 @@ AngularConnector.prototype.request = function (params, cb) { url: this.host.makeUrl(params), data: params.body, cache: false, - timeout: params.timeout !== Infinity ? params.timeout : 0 + timeout: _.has(params, 'requestTimeout') ? this.requestTimeout : 10000 }).then(function (response) { cb(null, response.data, response.status); }, function (err) { diff --git a/src/lib/connectors/http.js b/src/lib/connectors/http.js index 83f90e458..0d796daee 100644 --- a/src/lib/connectors/http.js +++ b/src/lib/connectors/http.js @@ -12,15 +12,12 @@ var handles = { http: require('http'), https: require('https') }; -var Log = require('../log'); var _ = require('../utils'); var errors = require('../errors'); var qs = require('querystring'); var KeepAliveAgent = require('agentkeepalive'); var ConnectionAbstract = require('../connection'); -var log = _.bindKey(process.stdout, 'write'); - /** * Connector used to talk to an elasticsearch node via HTTP * @@ -29,29 +26,31 @@ var log = _.bindKey(process.stdout, 'write'); * @param {Number} [config.maxSockets=10] - the maximum number of sockets that will be opened to this node * @param {Number} [config.maxFreeSockets=10] - this maximum number of sockets that can sit idle to this node * @param {Number} [config.maxKeepAliveTime=300000] - an idle timeout for the connections to this node. If your + * @param {Number} [config.timeout=10000] - an idle timeout for the connections to this node. If your * maxSockets is much higher than your average concurrent usage, this timeout will cause sockets to close which * can be interpreted as "bad" behavior for clients. */ function HttpConnector(host, config) { - config = _.defaults(config || {}, { - maxSockets: 10, - maxFreeSockets: 10, - maxKeepAliveTime: 3e5 // 5 minutes - }); ConnectionAbstract.call(this, host, config); this.hand = handles[this.host.protocol]; + if (!this.hand) { + throw new TypeError('Invalid protocol "' + this.host.protocol + + '", expected one of ' + _.keys(handles).join(', ')); + } + + config = _.defaults(config || {}, { + maxSockets: 10, + maxFreeSockets: this.hand.Agent.defaultMaxSockets, + maxKeepAliveTime: 3e5 // 5 minutes + }); + this.agent = new KeepAliveAgent({ keepAlive: true, maxSockets: config.maxSockets, - maxFreeSockets: config.maxFreeSockets || this.hand.Agent.defaultMaxSockets, + maxFreeSockets: config.maxFreeSockets, keepAliveMsecs: config.keepAliveMsecs }); - - this.log = config.log; - if (!_.isObject(this.log)) { - this.log = new Log(); - } } _.inherits(HttpConnector, ConnectionAbstract); @@ -70,16 +69,13 @@ HttpConnector.prototype.makeReqParams = function (params) { agent: this.agent }; - var query = this.host.query ? this.host.query : null; + var query = this.host.query ? _.clone(this.host.query) : {}; if (params.query) { - query = _.defaults({}, - typeof params.query === 'string' ? qs.parse(params.query) : params.query, - query || {} - ); + _.extend(query, typeof params.query === 'string' ? qs.parse(params.query) : params.query); } - if (query) { + if (_.size(query)) { reqParams.path = reqParams.path + '?' + qs.stringify(query); } @@ -92,7 +88,7 @@ HttpConnector.prototype.request = function (params, cb) { var request; var response; var status = 0; - var timeout = params.timeout || this.config.timeout; + var requestTimeout = _.has(params, 'requestTimeout') ? this.requestTimeout : 10000; var log = this.log; var reqParams = this.makeReqParams(params); @@ -132,17 +128,23 @@ HttpConnector.prototype.request = function (params, cb) { request.on('error', cleanUp); - if (timeout !== Infinity) { + if (requestTimeout) { // timeout for the entire request. timeoutId = setTimeout(function () { request.abort(); - request.emit('error', new errors.RequestTimeout('Request timed out at ' + timeout + 'ms')); - }, timeout); + request.emit('error', new errors.RequestTimeout('Request timed out at ' + requestTimeout + 'ms')); + }, requestTimeout); } request.setNoDelay(true); request.setSocketKeepAlive(true); + request.chunkedEncoding = false; - request.end(params.body); + if (params.body) { + request.setHeader('Content-Length', params.body.length); + request.end(params.body); + } else { + request.end(); + } this.requestCount++; }; diff --git a/src/lib/connectors/jquery.js b/src/lib/connectors/jquery.js index 95ceebaf1..753fa4359 100644 --- a/src/lib/connectors/jquery.js +++ b/src/lib/connectors/jquery.js @@ -10,7 +10,21 @@ module.exports = JqueryConnector; function JqueryConnector() {} JqueryConnector.prototype.request = function (params, cb) { - jQuery.ajax(params).done(cb); + var ajax = { + data: params.body, + dataType: 'json', + headers: params.headers, + timeout: params.requestTimeout, + done: cb + }; + + if (params.auth) { + var auths = params.auth.split(':'); + ajax.username = auths[0]; + ajax.password = auths[1]; + } + + return jQuery.ajax(ajax); }; diff --git a/src/lib/connectors/xhr.js b/src/lib/connectors/xhr.js index 13c178dac..e1f0502fd 100644 --- a/src/lib/connectors/xhr.js +++ b/src/lib/connectors/xhr.js @@ -50,10 +50,10 @@ if (!getXhr) { XhrConnector.prototype.request = function (params, cb) { var xhr = getXhr(); - var timeout = params.timeout ? params.timeout : 10000; + var requestTimeout = _.has(params, 'requestTimeout') ? this.requestTimeout : 10000; var timeoutId; var url = this.host.makeUrl(params); - var log = this.config.log; + var log = this.log; var async = params.async === false ? false : asyncDefault; if (params.auth) { @@ -71,12 +71,12 @@ XhrConnector.prototype.request = function (params, cb) { } }; - if (timeout !== Infinity) { + if (requestTimeout) { timeoutId = setTimeout(function () { xhr.onreadystatechange = _.noop; xhr.abort(); cb(new TimeoutError()); - }, timeout); + }, requestTimeout); } xhr.send(params.body || void 0); diff --git a/src/lib/host.js b/src/lib/host.js index 50b147c7a..4a3f4f344 100644 --- a/src/lib/host.js +++ b/src/lib/host.js @@ -10,18 +10,19 @@ var _ = require('./utils'); var startsWithProtocolRE = /^([a-z]+:)?\/\//; -// simple reference used when formatting as a url -var defaultPort = { - http: 80, - https: 443 -}; - var urlParseFields = [ 'protocol', 'hostname', 'pathname', 'port', 'auth', 'query' ]; var simplify = ['host', 'path']; +// simple reference used when formatting as a url +// and defines when parsing from a string +Host.defaultPorts = { + http: 80, + https: 443 +}; + function Host(config) { config = config || {}; @@ -38,6 +39,17 @@ function Host(config) { config = 'http://' + config; } config = _.pick(url.parse(config, false, true), urlParseFields); + // default logic for the port is to use 9200 for the default. When a string is specified though, + // we will use the default from the protocol of the string. + if (!config.port) { + var proto = config.protocol || 'http'; + if (proto.charAt(proto.length - 1) === ':') { + proto = proto.substring(0, proto.length - 1); + } + if (Host.defaultPorts[proto]) { + config.port = Host.defaultPorts[proto]; + } + } } if (_.isObject(config)) { @@ -68,15 +80,16 @@ function Host(config) { } // make sure that the port is a number - if (typeof this.port !== 'number') { + if (_.isNumeric(this.port)) { this.port = parseInt(this.port, 10); - if (isNaN(this.port)) { - this.port = 9200; - } + } else { + this.port = 9200; } // make sure the path starts with a leading slash - if (this.path && this.path.charAt(0) !== '/') { + if (this.path === '/') { + this.path = ''; + } else if (this.path && this.path.charAt(0) !== '/') { this.path = '/' + (this.path || ''); } @@ -90,7 +103,7 @@ Host.prototype.makeUrl = function (params) { params = params || {}; // build the port var port = ''; - if (this.port !== defaultPort[this.protocol]) { + if (this.port !== Host.defaultPorts[this.protocol]) { // add an actual port port = ':' + this.port; } diff --git a/src/lib/logger.js b/src/lib/logger.js index 054fb095b..8b1b58819 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -143,8 +143,8 @@ LoggerAbstract.prototype.onDebug = _.handler(function (msg) { * @param {String} msg - The message to be logged * @return {undefined} */ -LoggerAbstract.prototype.onTrace = _.handler(function (message) { - this.write('TRACE', message); +LoggerAbstract.prototype.onTrace = _.handler(function (message, curlCall) { + this.write('TRACE', message + '\n' + curlCall); }); diff --git a/src/lib/nodes_to_host.js b/src/lib/nodes_to_host.js new file mode 100644 index 000000000..87edcdc00 --- /dev/null +++ b/src/lib/nodes_to_host.js @@ -0,0 +1,20 @@ +var _ = require('./utils'); +var extractHostPartsRE = /\[([^:]+):(\d+)\]/; + +module.exports = function (nodes) { + var hosts = []; + _.each(nodes, function (node, id) { + var hostnameMatches = extractHostPartsRE.exec(node.http_address); + hosts.push({ + host: hostnameMatches[1], + port: hostnameMatches[2], + _meta: { + id: id, + name: node.name, + hostname: node.hostname, + version: node.version + } + }); + }); + return hosts; +}; diff --git a/src/lib/transport.js b/src/lib/transport.js index 530f4bb71..cb6e89451 100644 --- a/src/lib/transport.js +++ b/src/lib/transport.js @@ -66,6 +66,10 @@ Transport.logs = { main: require('./log') }; +Transport.nodesToHostCallbacks = { + main: require('./nodes_to_host') +}; + /** * Perform a request with the client's transport * @@ -100,7 +104,7 @@ Transport.prototype.request = function (params, cb) { } params.req = { - timeout: params.timeout, + requestTimeout: params.requestTimeout, method: params.method, path: params.path, query: params.query, diff --git a/test/fixtures/large_response.json b/test/fixtures/large_response.json new file mode 100644 index 000000000..e69de29bb diff --git a/test/unit/test_client_action.js b/test/unit/test_client_action.js index 3ed4093b0..518023914 100644 --- a/test/unit/test_client_action.js +++ b/test/unit/test_client_action.js @@ -79,7 +79,6 @@ describe('Client Action runner', function () { (function () { action({}, function () {}); }).should.throw('proxy function called'); - }); it('provides the proper context', function (done) { @@ -630,34 +629,34 @@ describe('Client Action runner', function () { }); }); - describe('passing of timeout', function () { - it('passes the timeout', function (done) { + describe('passing requestTimeout', function () { + it('passes passes the spec value by default', function (done) { var action = makeClientAction({ - timeout: 100 + requestTimeout: 100 }); action({}, function (err, params) { - params.timeout.should.be.exactly(100); + params.requestTimeout.should.be.exactly(100); done(); }); }); - it('passes the provided value for timeout', function (done) { + it('passes the provided value', function (done) { var action = makeClientAction({ - timeout: 100 + requestTimeout: 100 }); - action({ timeout: 3000 }, function (err, params) { - params.timeout.should.be.exactly(3000); + action({ requestTimeout: 3000 }, function (err, params) { + params.requestTimeout.should.be.exactly(3000); done(); }); }); - it('uses 10000 as the default timeout', function (done) { + it('passes nothing be default', function (done) { var action = makeClientAction({}); action({}, function (err, params) { - params.timeout.should.be.exactly(10000); + should(params.requestTimeout).be.exactly(void 0); done(); }); }); @@ -787,7 +786,7 @@ describe('Client Action runner', function () { b: '3w', q: 'beep', body: '{ "mmm": "json" }', - timeout: 1000, + requestTimeout: 1000, method: 'head', ignore: 201 }, diff --git a/test/unit/test_host.js b/test/unit/test_host.js index 8c604db4d..10fd946b1 100644 --- a/test/unit/test_host.js +++ b/test/unit/test_host.js @@ -10,7 +10,7 @@ describe('Host class', function () { protocol: 'http', host: 'localhost', port: 9200, - path: '/', + path: '', auth: null, query: {} }); @@ -31,18 +31,35 @@ describe('Host class', function () { host.headers.should.be.exactly(headers); }); - it('accepts a string for the entire url', function () { - var host = new Host('john:dude@pizza.com:420/pizza/cheese?shrooms=true'); + describe('from a string', function () { + it('accepts a string for the entire url', function () { + var host = new Host('john:dude@pizza.com:420/pizza/cheese?shrooms=true'); - host.should.eql({ - protocol: 'http', - host: 'pizza.com', - port: 420, - path: '/pizza/cheese', - auth: 'john:dude', - query: { - shrooms: 'true' - } + host.should.eql({ + protocol: 'http', + host: 'pizza.com', + port: 420, + path: '/pizza/cheese', + auth: 'john:dude', + query: { + shrooms: 'true' + } + }); + }); + + it('uses the default port based on the protocol', function () { + var host; + + host = new Host('https://google.com'); + host.port.should.eql(443); + + host = new Host('http://google.com'); + host.port.should.eql(80); + + Host.defaultPorts.trift = 9300; + host = new Host('thrift://google.com'); + host.port.should.eql(9200); + delete Host.defaultPorts.trift; }); }); @@ -85,7 +102,7 @@ describe('Host class', function () { protocol: 'http', host: 'localhost', port: 9200, - path: '/', + path: '', auth: null, query: {} }); @@ -123,12 +140,21 @@ describe('Host class', function () { host.makeUrl({ path: '/this and that'}) .should.eql('http://localhost:9200/prefix//this and that'); }); - }); - describe('#toString', function () { - it('just calls makeUrl with no parameters', function () { + it('creates proper url without any params', function () { + var host = new Host({}); + host.makeUrl().should.eql('http://localhost:9200/'); + host = new Host({ host: 'john', port: 80 }); + host.makeUrl().should.eql('http://john/'); + + host = new Host({ host: 'italy', path: '/pie' }); + host.makeUrl().should.eql('http://italy:9200/pie'); }); }); + describe('#toString', function () { + // just calls makeUrl without any params + }); + }); diff --git a/test/unit/test_http_connection.js b/test/unit/test_http_connection.js deleted file mode 100644 index e73c8aa23..000000000 --- a/test/unit/test_http_connection.js +++ /dev/null @@ -1,58 +0,0 @@ -describe('Http Connector', function () { - - var Host = require('../../src/lib/host'); - var HttpConnection = require('../../src/lib/connectors/http'); - - describe('#makeReqParams', function () { - - it('properly reads the host object', function () { - var host = new Host('john:dude@pizza.com:9200/pizza/cheese?shrooms=true'); - var con = new HttpConnection(host, {}); - var reqParams = con.makeReqParams(); - - reqParams.should.eql({ - method: 'GET', - protocol: 'http:', - auth: 'john:dude', - hostname: 'pizza.com', - port: 9200, - path: '/pizza/cheese?shrooms=true', - headers: host.headers, - agent: con.agent - }); - }); - - it('accepts merges a query object with the hosts\'', function () { - var con = new HttpConnection(new Host({ - query: { - user_id: 123 - } - })); - - var reqParams = con.makeReqParams({ - query: { - jvm: 'yes' - } - }); - - reqParams.should.include({ - path: '/?jvm=yes&user_id=123' - }); - }); - - // it('works with an empty query', function () { - // var reqParams = con.makeReqParams(); - - // reqParams.should.include({ - // method: 'GET', - // path: '/' - // }); - - // Object.keys(reqParams).should.not.include([ - // 'host', 'pathname', 'query' - // ]); - // }); - - }); - -}); diff --git a/test/unit/test_http_connector.js b/test/unit/test_http_connector.js new file mode 100644 index 000000000..0c3e7c635 --- /dev/null +++ b/test/unit/test_http_connector.js @@ -0,0 +1,306 @@ +describe('Http Connector', function () { + + var should = require('should'); + var Host = require('../../src/lib/host'); + var HttpConnection = require('../../src/lib/connectors/http'); + var ConnectionAbstract = require('../../src/lib/connection'); + + describe('Constructor', function () { + it('creates an object that extends ConnectionAbstract', function () { + var con = new HttpConnection(new Host()); + con.should.be.an.instanceOf(ConnectionAbstract); + }); + + it('sets certain defaults', function () { + var con = new HttpConnection(new Host()); + + con.hand.should.be.exactly(require('http')); + // con.requestTimeout + // maxSockets + // maxFreeSockets + // maxKeepAliveTime + // requestTimeout + }); + + it('expects one the host to have a protocol of http or https', function () { + (function () { + var con = new HttpConnection(new Host('thrifty://es.com/stuff')); + }).should.throw(/invalid protocol/i); + }); + }); + + describe('#makeReqParams', function () { + + it('properly reads the host object', function () { + var host = new Host('john:dude@pizza.com:9200/pizza/cheese?shrooms=true'); + var con = new HttpConnection(host, {}); + var reqParams = con.makeReqParams(); + + reqParams.should.eql({ + method: 'GET', + protocol: 'http:', + auth: 'john:dude', + hostname: 'pizza.com', + port: 9200, + path: '/pizza/cheese?shrooms=true', + headers: host.headers, + agent: con.agent + }); + }); + + it('merges a query object with the hosts\'', function () { + var con = new HttpConnection(new Host({ + query: { + user_id: 123 + } + })); + + var reqParams = con.makeReqParams({ + query: { + jvm: 'yes' + } + }); + + reqParams.should.include({ + path: '?user_id=123&jvm=yes' + }); + }); + + it('merges the path prefex', function () { + var con = new HttpConnection(new Host('https://google.com/path/prefix/for/user/1')); + var reqParams = con.makeReqParams({ + method: 'GET', + path: '/items', + query: { + q: 'pizza' + } + }); + + reqParams.should.eql({ + method: 'GET', + protocol: 'https:', + auth: null, + hostname: 'google.com', + port: 443, + path: '/path/prefix/for/user/1/items?q=pizza', + headers: undefined, + agent: con.agent + }); + }); + + it('merges the query', function () { + var con = new HttpConnection(new Host('http://google.com/pref-x?userId=12345&token=42069')); + + var reqParams = con.makeReqParams({ + method: 'PUT', + path: '/stuff', + query: { + q: 'pizza' + } + }); + + reqParams.should.eql({ + method: 'PUT', + protocol: 'http:', + auth: null, + hostname: 'google.com', + port: 80, + path: '/pref-x/stuff?userId=12345&token=42069&q=pizza', + headers: undefined, + agent: con.agent + }); + }); + + it('Works well with minimum params', function () { + var con = new HttpConnection(new Host('http://google.com')); + + var reqParams = con.makeReqParams({ + method: 'PUT', + path: '/stuff' + }); + + reqParams.should.eql({ + method: 'PUT', + protocol: 'http:', + auth: null, + hostname: 'google.com', + port: 80, + path: '/stuff', + headers: undefined, + agent: con.agent + }); + }); + }); + + describe('#request', function () { + var http = require('http'); + var https = require('https'); + var sinon = require('sinon'); + var util = require('util'); + + function FakeRequest() { + sinon.stub(this, 'end'); + sinon.stub(this, 'write'); + this.log = sinon.stub(this.log); + } + util.inherits(FakeRequest, http.ClientRequest); + + function reqMethodStub(params, cb) { + var req = new FakeRequest(); + process.nextTick(function () { + // causes the request to quit and callback + req.emit('error'); + }); + return req; + } + + beforeEach(function () { + sinon.stub(http, 'request', reqMethodStub); + sinon.stub(https, 'request', reqMethodStub); + }); + + afterEach(function () { + http.request.restore(); + https.request.restore(); + }); + + it('calls http based on the host', function (done) { + var con = new HttpConnection(new Host('http://google.com')); + con.request({}, function () { + http.request.callCount.should.eql(1); + https.request.callCount.should.eql(0); + done(); + }); + }); + + it('calls https based on the host', function (done) { + var con = new HttpConnection(new Host('https://google.com')); + con.request({}, function () { + http.request.callCount.should.eql(0); + https.request.callCount.should.eql(1); + done(); + }); + }); + + it('logs error events, and sets the connection to dead when an error occurs', function (done) { + var con = new HttpConnection(new Host('http://google.com')); + + sinon.stub(con.log); + + http.request.restore(); + sinon.stub(http, 'request', function (params, cb) { + var req = new FakeRequest(); + process.nextTick(function () { + // causes the request to quit and callback + req.emit('error', new Error('actual error')); + }); + return req; + }); + + con.request({}, function (err) { + // error should have been sent to the + err.message.should.eql('actual error'); + + // logged the error and the trace log + con.log.error.callCount.should.eql(1); + con.log.trace.callCount.should.eql(1); + con.log.info.callCount.should.eql(0); + con.log.warning.callCount.should.eql(0); + con.log.debug.callCount.should.eql(0); + + // set status to dead + con.status.should.eql('dead'); + + done(); + }); + }); + + it('logs error events, and sets the connection to dead', function (done) { + var con = new HttpConnection(new Host('http://google.com')); + + sinon.stub(con.log); + + http.request.restore(); + sinon.stub(http, 'request', function (params, cb) { + var req = new FakeRequest(); + process.nextTick(function () { + // causes the request to quit and callback + req.emit('error', new Error('actual error')); + }); + return req; + }); + + con.request({}, function (err) { + // error should have been sent to the + err.message.should.eql('actual error'); + + // logged the error + con.log.error.callCount.should.eql(1); + con.log.error.lastCall.args[0].message.should.eql('actual error'); + + // set status to dead + con.status.should.eql('dead'); + + done(); + }); + }); + }); + + describe('Request Implementation', function () { + var server; + var nock = require('nock'); + nock.disableNetConnect(); + var host = new Host('http://esjs.com:9200'); + + beforeEach(function () { + server = nock('http://esjs.com:9200'); + }); + + afterEach(function () { + server.done(); + nock.restore(); + }); + + it('collects the whole request body', function (done) { + var con = new HttpConnection(host); + + var body = '{ "USER": "doc" }'; + server + .get('/users/1') + .reply(200, body); + + con.request({ + method: 'GET', + path: '/users/1' + }, function (err, resp, status) { + should(err).not.exist; + resp.should.eql(body); + status.should.eql(200); + done(); + }); + }); + + it('Catches network errors and passes back the error', function () { + var con = new HttpConnection(host); + + var body = '{ "USER": "doc" }'; + server + .get('/users/1') + .reply(200, { + + }); + + con.request({ + method: 'GET', + path: '/users/1' + }, function (err, resp, status) { + should(err).not.exist; + resp.should.eql(body); + status.should.eql(200); + done(); + }); + }); + + }); + +});