UNPKG

@opensearch-project/opensearch

Version:

The official OpenSearch client for Node.js

61 lines (52 loc) 2.94 kB
/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * */ /* * This file was generated from the OpenSearch API Spec. Do NOT edit it * manually. If you want to make changes, either update the spec or * modify the API generator. */ 'use strict'; const { normalizeArguments, parsePathParam, handleMissingParam } = require('../utils'); /** * Removes a document from the index. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/document-apis/delete-document/ - delete} * * @memberOf API-Core * * @param {object} params * @param {number} [params.if_primary_term] - Only perform the operation if the document has this primary term. * @param {number} [params.if_seq_no] - Only perform the operation if the document has this sequence number. * @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`. * @param {string} [params.routing] - Custom value used to route operations to a specific shard. * @param {string} [params.timeout] - Period to wait for active shards. * @param {number} [params.version] - Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. * @param {string} [params.version_type] - Specific version type: `external`, `external_gte`. * @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`). * @param {string} params.id - Unique identifier for the document. * @param {string} params.index - Name of the target index. * * @param {TransportRequestOptions} [options] - Options for {@link Transport#request} * @param {function} [callback] - Callback that handles errors and response * * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} */ function deleteFunc(params, options, callback) { [params, options, callback] = normalizeArguments(params, options, callback); if (params.id == null) return handleMissingParam('id', this, callback); if (params.index == null) return handleMissingParam('index', this, callback); let { body, id, index, ...querystring } = params; id = parsePathParam(id); index = parsePathParam(index); const path = '/' + index + '/_doc/' + id; const method = 'DELETE'; body = body || ''; return this.transport.request({ method, path, querystring, body }, options, callback); } module.exports = deleteFunc;