|
| 1 | +/* |
| 2 | + * Copyright OpenSearch Contributors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + * |
| 5 | + * The OpenSearch Contributors require contributions made to |
| 6 | + * this file be licensed under the Apache-2.0 license or a |
| 7 | + * compatible open source license. |
| 8 | + * |
| 9 | + */ |
| 10 | + |
| 11 | +/* |
| 12 | + * This file was generated from the OpenSearch API Spec. Do NOT edit it |
| 13 | + * manually. If you want to make changes, either update the spec or |
| 14 | + * modify the API generator. |
| 15 | + */ |
| 16 | + |
| 17 | +'use strict'; |
| 18 | + |
| 19 | +const { normalizeArguments, parsePathParam, handleMissingParam } = require('../utils'); |
| 20 | + |
| 21 | +/** |
| 22 | + * Allows to perform multiple index/update/delete operations using request response streaming. |
| 23 | + * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/document-apis/bulk-streaming/ - bulk_stream} |
| 24 | + * |
| 25 | + * @memberOf API-Core |
| 26 | + * |
| 27 | + * @param {object} params |
| 28 | + * @param {string} [params._source] - `true` or `false` to return the `_source` field or not, or a list of fields to return. |
| 29 | + * @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude from the response. |
| 30 | + * @param {string} [params._source_includes] - A comma-separated list of source fields to include in the response. |
| 31 | + * @param {string} [params.batch_interval] - Specifies for how long bulk operations should be accumulated into a batch before sending the batch to data nodes. |
| 32 | + * @param {number} [params.batch_size] - Specifies how many bulk operations should be accumulated into a batch before sending the batch to data nodes. |
| 33 | + * @param {string} [params.pipeline] - ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. |
| 34 | + * @param {string} [params.refresh] - If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. |
| 35 | + * @param {boolean} [params.require_alias=false] - If `true`, the request's actions must target an index alias. |
| 36 | + * @param {string} [params.routing] - Custom value used to route operations to a specific shard. |
| 37 | + * @param {string} [params.timeout] - Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. |
| 38 | + * @param {string} [params.type] - Default document type for items which don't provide one. |
| 39 | + * @param {string} [params.wait_for_active_shards] - The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). |
| 40 | + * @param {string} [params.index] - Name of the data stream, index, or index alias to perform bulk actions on. |
| 41 | + * @param {array} params.body - The operation definition and data (action-data pairs), separated by newlines |
| 42 | + * |
| 43 | + * @param {TransportRequestOptions} [options] - Options for {@link Transport#request} |
| 44 | + * @param {function} [callback] - Callback that handles errors and response |
| 45 | + * |
| 46 | + * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} |
| 47 | + */ |
| 48 | +function bulkStreamFunc(params, options, callback) { |
| 49 | + [params, options, callback] = normalizeArguments(params, options, callback); |
| 50 | + if (params.body == null) return handleMissingParam('body', this, callback); |
| 51 | + |
| 52 | + let { body, index, ...querystring } = params; |
| 53 | + index = parsePathParam(index); |
| 54 | + |
| 55 | + const path = ['/', index, '/_bulk/stream'].filter(c => c).join('').replace('//', '/'); |
| 56 | + const method = index == null ? 'POST' : 'PUT'; |
| 57 | + |
| 58 | + return this.transport.request({ method, path, querystring, bulkBody: body }, options, callback); |
| 59 | +} |
| 60 | + |
| 61 | +module.exports = bulkStreamFunc; |
0 commit comments