diff --git a/api/api/bulk.js b/api/api/bulk.js index cf09dbbdd..505fe99ec 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -50,7 +50,9 @@ function buildBulk (opts) { 'type', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'pipeline', 'pretty', 'human', @@ -62,7 +64,9 @@ function buildBulk (opts) { const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index c760a1dab..8450c1eb2 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -29,7 +29,6 @@ function buildDeleteByQuery (opts) { * Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {string} analyzer - The analyzer to use for the query string * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) * @param {enum} default_operator - The default operator for query string query (AND or OR) @@ -86,7 +85,9 @@ function buildDeleteByQuery (opts) { 'sort', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'terminate_after', 'stats', 'version', @@ -114,7 +115,9 @@ function buildDeleteByQuery (opts) { searchType: 'search_type', searchTimeout: 'search_timeout', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', terminateAfter: 'terminate_after', requestCache: 'request_cache', waitForActiveShards: 'wait_for_active_shards', @@ -147,12 +150,6 @@ function buildDeleteByQuery (opts) { return handleError(err, callback) } - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -160,7 +157,7 @@ function buildDeleteByQuery (opts) { } var warnings = [] - var { method, body, index, type, ...querystring } = params + var { method, body, index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -174,11 +171,7 @@ function buildDeleteByQuery (opts) { var path = '' - if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query' - } else { - path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' - } + path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' // build request object const request = { diff --git a/api/api/exists.js b/api/api/exists.js index b0647a16d..41128f83e 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -53,7 +53,9 @@ function buildExists (opts) { 'routing', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'version', 'version_type', 'pretty', @@ -66,7 +68,9 @@ function buildExists (opts) { const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 1d94e75d1..7eece25e5 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -51,7 +51,9 @@ function buildExistsSource (opts) { 'routing', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'version', 'version_type', 'pretty', @@ -63,7 +65,9 @@ function buildExistsSource (opts) { const snakeCase = { _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' diff --git a/api/api/explain.js b/api/api/explain.js index ef8c82a9b..1f6602e79 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -60,7 +60,9 @@ function buildExplain (opts) { 'routing', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'pretty', 'human', 'error_trace', @@ -73,7 +75,9 @@ function buildExplain (opts) { defaultOperator: 'default_operator', storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/get.js b/api/api/get.js index 38d95b1c0..670668dc6 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -53,7 +53,9 @@ function buildGet (opts) { 'routing', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'version', 'version_type', 'pretty', @@ -66,7 +68,9 @@ function buildGet (opts) { const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' diff --git a/api/api/get_source.js b/api/api/get_source.js index c74c9f6aa..e9f0491c1 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -51,7 +51,9 @@ function buildGetSource (opts) { 'routing', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'version', 'version_type', 'pretty', @@ -63,7 +65,9 @@ function buildGetSource (opts) { const snakeCase = { _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' diff --git a/api/api/mget.js b/api/api/mget.js index 7a0b5ee4c..b32742a97 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -49,7 +49,9 @@ function buildMget (opts) { 'routing', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'pretty', 'human', 'error_trace', @@ -60,7 +62,9 @@ function buildMget (opts) { const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/msearch.js b/api/api/msearch.js index 668ec0a6f..fd1c89a06 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -29,7 +29,6 @@ function buildMsearch (opts) { * Perform a [msearch](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html) request * * @param {list} index - A comma-separated list of index names to use as default - * @param {list} type - A comma-separated list of document types to use as default * @param {enum} search_type - Search operation type * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response @@ -85,12 +84,6 @@ function buildMsearch (opts) { return handleError(err, callback) } - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -98,7 +91,7 @@ function buildMsearch (opts) { } var warnings = [] - var { method, body, index, type, ...querystring } = params + var { method, body, index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -112,9 +105,7 @@ function buildMsearch (opts) { var path = '' - if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' - } else if ((index) != null) { + if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_msearch' } else { path = '/' + '_msearch' diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 2a6cb3514..527de8da3 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -29,7 +29,6 @@ function buildMsearchTemplate (opts) { * Perform a [msearch_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) request * * @param {list} index - A comma-separated list of index names to use as default - * @param {list} type - A comma-separated list of document types to use as default * @param {enum} search_type - Search operation type * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute @@ -79,12 +78,6 @@ function buildMsearchTemplate (opts) { return handleError(err, callback) } - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -92,7 +85,7 @@ function buildMsearchTemplate (opts) { } var warnings = [] - var { method, body, index, type, ...querystring } = params + var { method, body, index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -106,9 +99,7 @@ function buildMsearchTemplate (opts) { var path = '' - if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template' - } else if ((index) != null) { + if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template' } else { path = '/' + '_msearch' + '/' + 'template' diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index 92d14c93c..4fee48798 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -29,7 +29,6 @@ function buildMtermvectors (opts) { * Perform a [mtermvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html) request * * @param {string} index - The index in which the document resides. - * @param {string} type - The type of the document. * @param {list} ids - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body * @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". * @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". @@ -87,12 +86,6 @@ function buildMtermvectors (opts) { options = {} } - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -100,7 +93,7 @@ function buildMtermvectors (opts) { } var warnings = [] - var { method, body, index, type, ...querystring } = params + var { method, body, index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -114,9 +107,7 @@ function buildMtermvectors (opts) { var path = '' - if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mtermvectors' - } else if ((index) != null) { + if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors' } else { path = '/' + '_mtermvectors' diff --git a/api/api/search.js b/api/api/search.js index 6a1726ee0..885dd59b0 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -29,7 +29,6 @@ function buildSearch (opts) { * Perform a [search](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {string} analyzer - The analyzer to use for the query string * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) * @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution @@ -99,7 +98,9 @@ function buildSearch (opts) { 'sort', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'terminate_after', 'stats', 'suggest_field', @@ -137,7 +138,9 @@ function buildSearch (opts) { expandWildcards: 'expand_wildcards', searchType: 'search_type', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', terminateAfter: 'terminate_after', suggestField: 'suggest_field', suggestMode: 'suggest_mode', @@ -169,12 +172,6 @@ function buildSearch (opts) { options = {} } - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -182,7 +179,7 @@ function buildSearch (opts) { } var warnings = [] - var { method, body, index, type, ...querystring } = params + var { method, body, index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -196,9 +193,7 @@ function buildSearch (opts) { var path = '' - if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' - } else if ((index) != null) { + if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_search' } else { path = '/' + '_search' diff --git a/api/api/search_template.js b/api/api/search_template.js index 5b6d53853..dc9431d05 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -29,7 +29,6 @@ function buildSearchTemplate (opts) { * Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -98,12 +97,6 @@ function buildSearchTemplate (opts) { return handleError(err, callback) } - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -111,7 +104,7 @@ function buildSearchTemplate (opts) { } var warnings = [] - var { method, body, index, type, ...querystring } = params + var { method, body, index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -125,9 +118,7 @@ function buildSearchTemplate (opts) { var path = '' - if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template' - } else if ((index) != null) { + if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template' } else { path = '/' + '_search' + '/' + 'template' diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 93092d9f9..47c0ae4ea 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -29,7 +29,6 @@ function buildTermvectors (opts) { * Perform a [termvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html) request * * @param {string} index - The index in which the document resides. - * @param {string} type - The type of the document. * @param {string} id - The id of the document, when not specified a doc param should be supplied. * @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. * @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. @@ -99,7 +98,7 @@ function buildTermvectors (opts) { } var warnings = [] - var { method, body, index, type, id, ...querystring } = params + var { method, body, index, id, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -113,12 +112,8 @@ function buildTermvectors (opts) { var path = '' - if ((index) != null && (type) != null && (id) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors' - } else if ((index) != null && (id) != null) { + if ((index) != null && (id) != null) { path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id) - } else if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors' } else { path = '/' + encodeURIComponent(index) + '/' + '_termvectors' } diff --git a/api/api/update.js b/api/api/update.js index 615a07aea..8059d3cb1 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -50,7 +50,9 @@ function buildUpdate (opts) { 'wait_for_active_shards', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'lang', 'parent', 'refresh', @@ -69,7 +71,9 @@ function buildUpdate (opts) { const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', retryOnConflict: 'retry_on_conflict', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 7d7d7bc47..017262d33 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -29,7 +29,6 @@ function buildUpdateByQuery (opts) { * Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request * * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {string} analyzer - The analyzer to use for the query string * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) * @param {enum} default_operator - The default operator for query string query (AND or OR) @@ -89,7 +88,9 @@ function buildUpdateByQuery (opts) { 'sort', '_source', '_source_excludes', + '_source_exclude', '_source_includes', + '_source_include', 'terminate_after', 'stats', 'version', @@ -118,7 +119,9 @@ function buildUpdateByQuery (opts) { searchType: 'search_type', searchTimeout: 'search_timeout', _sourceExcludes: '_source_excludes', + _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', + _sourceInclude: '_source_include', terminateAfter: 'terminate_after', versionType: 'version_type', requestCache: 'request_cache', @@ -148,12 +151,6 @@ function buildUpdateByQuery (opts) { return handleError(err, callback) } - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) @@ -161,7 +158,7 @@ function buildUpdateByQuery (opts) { } var warnings = [] - var { method, body, index, type, ...querystring } = params + var { method, body, index, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { @@ -175,11 +172,7 @@ function buildUpdateByQuery (opts) { var path = '' - if ((index) != null && (type) != null) { - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query' - } else { - path = '/' + encodeURIComponent(index) + '/' + '_update_by_query' - } + path = '/' + encodeURIComponent(index) + '/' + '_update_by_query' // build request object const request = { diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 5f1134da4..3afecde48 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -30,6 +30,8 @@ export interface Generic { export interface Bulk extends Generic { index?: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; wait_for_active_shards?: string; refresh?: 'true' | 'false' | 'wait_for'; routing?: string; @@ -387,7 +389,8 @@ export interface Delete extends Generic { export interface DeleteByQuery extends Generic { index: string | string[]; - type?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; analyzer?: string; analyze_wildcard?: boolean; default_operator?: 'AND' | 'OR'; @@ -438,6 +441,8 @@ export interface Exists extends Generic { id: string; index: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; stored_fields?: string | string[]; parent?: string; preference?: string; @@ -455,6 +460,8 @@ export interface ExistsSource extends Generic { id: string; index: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; parent?: string; preference?: string; realtime?: boolean; @@ -471,6 +478,8 @@ export interface Explain extends Generic { id: string; index: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; analyze_wildcard?: boolean; analyzer?: string; default_operator?: 'AND' | 'OR'; @@ -500,6 +509,8 @@ export interface Get extends Generic { id: string; index: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; stored_fields?: string | string[]; parent?: string; preference?: string; @@ -522,6 +533,8 @@ export interface GetSource extends Generic { id: string; index: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; parent?: string; preference?: string; realtime?: boolean; @@ -933,6 +946,8 @@ export interface IngestSimulate extends Generic { export interface Mget extends Generic { index?: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; stored_fields?: string | string[]; preference?: string; realtime?: boolean; @@ -946,7 +961,6 @@ export interface Mget extends Generic { export interface Msearch extends Generic { index?: string | string[]; - type?: string | string[]; search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; max_concurrent_searches?: number; typed_keys?: boolean; @@ -959,7 +973,6 @@ export interface Msearch extends Generic { export interface MsearchTemplate extends Generic { index?: string | string[]; - type?: string | string[]; search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; typed_keys?: boolean; max_concurrent_searches?: number; @@ -970,7 +983,6 @@ export interface MsearchTemplate extends Generic { export interface Mtermvectors extends Generic { index?: string; - type?: string; ids?: string | string[]; term_statistics?: boolean; field_statistics?: boolean; @@ -1086,7 +1098,8 @@ export interface Scroll extends Generic { export interface Search extends Generic { index?: string | string[]; - type?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; analyzer?: string; analyze_wildcard?: boolean; ccs_minimize_roundtrips?: boolean; @@ -1144,7 +1157,6 @@ export interface SearchShards extends Generic { export interface SearchTemplate extends Generic { index?: string | string[]; - type?: string | string[]; ignore_unavailable?: boolean; ignore_throttled?: boolean; allow_no_indices?: boolean; @@ -1249,7 +1261,6 @@ export interface TasksList extends Generic { export interface Termvectors extends Generic { index: string; - type?: string; id?: string; term_statistics?: boolean; field_statistics?: boolean; @@ -1270,6 +1281,8 @@ export interface Update extends Generic { id: string; index: string; type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; wait_for_active_shards?: string; _source?: string | string[]; _source_excludes?: string | string[]; @@ -1287,7 +1300,8 @@ export interface Update extends Generic { export interface UpdateByQuery extends Generic { index: string | string[]; - type?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; analyzer?: string; analyze_wildcard?: boolean; default_operator?: 'AND' | 'OR'; diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 3e2029d82..d9f1a3eca 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -1160,9 +1160,6 @@ link:{ref}/docs-delete-by-query.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices -|`type` -|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - |`analyzer` |`string` - The analyzer to use for the query string @@ -2930,9 +2927,6 @@ link:{ref}/search-multi-search.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to use as default -|`type` -|`string, string[]` - A comma-separated list of document types to use as default - |`search_type` or `searchType` |`'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch'` - Search operation type @@ -2973,9 +2967,6 @@ link:{ref}/search-multi-search.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to use as default -|`type` -|`string, string[]` - A comma-separated list of document types to use as default - |`search_type` or `searchType` |`'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch'` - Search operation type @@ -3008,9 +2999,6 @@ link:{ref}/docs-multi-termvectors.html[Reference] |`index` |`string` - The index in which the document resides. -|`type` -|`string` - The type of the document. - |`ids` |`string, string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body @@ -3384,9 +3372,6 @@ link:{ref}/search-search.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices -|`type` -|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - |`analyzer` |`string` - The analyzer to use for the query string @@ -3569,9 +3554,6 @@ link:{ref}/search-template.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices -|`type` -|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -3900,9 +3882,6 @@ link:{ref}/docs-termvectors.html[Reference] |`index` |`string` - The index in which the document resides. -|`type` -|`string` - The type of the document. - |`id` |`string` - The id of the document, when not specified a doc param should be supplied. @@ -4020,9 +3999,6 @@ link:{ref}/docs-update-by-query.html[Reference] |`index` |`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices -|`type` -|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - |`analyzer` |`string` - The analyzer to use for the query string diff --git a/scripts/generate.js b/scripts/generate.js index df47b783e..79b7e2b17 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -69,7 +69,7 @@ function start (opts) { writeFileSync( requestParamsOutputFile, - generateRequestTypes(allSpec), + generateRequestTypes(opts.branch || opts.tag, allSpec), { encoding: 'utf8' } ) @@ -113,7 +113,7 @@ function start (opts) { const spec = require(join(apiFolder, file)) allSpec.push(spec) - const code = generate(spec, common) + const code = generate(opts.branch || opts.tag, spec, common) const filePath = join(apiOutputFolder, `${file.slice(0, file.lastIndexOf('.'))}.js`) writeFileSync(filePath, code, { encoding: 'utf8' }) diff --git a/scripts/utils/generateApis.js b/scripts/utils/generateApis.js index 0f48503e2..bde344e03 100644 --- a/scripts/utils/generateApis.js +++ b/scripts/utils/generateApis.js @@ -22,11 +22,16 @@ 'use strict' const dedent = require('dedent') +const semver = require('semver') const allowedMethods = { noBody: ['GET', 'HEAD', 'DELETE'], body: ['POST', 'PUT', 'DELETE'] } +// if a parameter is depracted in a minor release +// we should be able to support it until the next major +const deprecatedParameters = require('./patch.json') + // list of apis that does not need any kind of validation // because of how the url is built or the `type` handling in ES7 const noPathValidation = [ @@ -63,7 +68,8 @@ const ndjsonApi = [ 'xpack.monitoring.bulk' ] -function generate (spec, common) { +function generate (version, spec, common) { + const release = semver.valid(version) ? semver.major(version) : version const api = Object.keys(spec)[0] const name = api .replace(/\.([a-z])/g, k => k[1].toUpperCase()) @@ -90,7 +96,11 @@ function generate (spec, common) { if (params[key].required) { required.push(key) } + acceptedQuerystring.push(key) + if (deprecatedParameters[release] && deprecatedParameters[release][key]) { + acceptedQuerystring.push(deprecatedParameters[release][key]) + } } for (const key in spec[api]) { diff --git a/scripts/utils/generateRequestTypes.js b/scripts/utils/generateRequestTypes.js index edba2fa68..b1e2bc72d 100644 --- a/scripts/utils/generateRequestTypes.js +++ b/scripts/utils/generateRequestTypes.js @@ -19,7 +19,11 @@ 'use strict' -function generate (api) { +const semver = require('semver') +const deprecatedParameters = require('./patch.json') + +function generate (version, api) { + const release = semver.valid(version) ? semver.major(version) : version var types = `/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -64,9 +68,20 @@ export interface Generic { const partsArr = Object.keys(parts) .map(k => ({ key: k, value: parts[k] })) + const deprecatedParametersToAdd = [] const paramsArr = Object.keys(params) .filter(k => !Object.keys(parts).includes(k)) - .map(k => ({ key: k, value: params[k] })) + .map(k => { + if (deprecatedParameters[release] && deprecatedParameters[release][k]) { + deprecatedParametersToAdd.push({ + key: deprecatedParameters[release][k], + value: params[k] + }) + } + return { key: k, value: params[k] } + }) + + deprecatedParametersToAdd.forEach(k => partsArr.push(k)) const genLine = e => { const optional = e.value.required ? '' : '?' diff --git a/scripts/utils/patch.json b/scripts/utils/patch.json new file mode 100644 index 000000000..392b305cb --- /dev/null +++ b/scripts/utils/patch.json @@ -0,0 +1,14 @@ +{ + "6": { + "_source_includes": "_source_include", + "_source_excludes": "_source_exclude" + }, + "7": { + "_source_includes": "_source_include", + "_source_excludes": "_source_exclude" + }, + "master": { + "_source_includes": "_source_include", + "_source_excludes": "_source_exclude" + } +}