From 868680b572b104532efef1bb0f0c6e2498df39ef Mon Sep 17 00:00:00 2001 From: Cameron Durham <17013462+camerondurham@users.noreply.github.com> Date: Wed, 8 Feb 2023 09:26:59 -0700 Subject: [PATCH] Allow fields in BulkOperation to be optional (#378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Allow fields in BulkOperation to be optional https://opensearch.org/docs/1.3/api-reference/document-apis/bulk/#request-body > All actions support the same metadata: _index, _id, and _require_alias. If you don’t provide an ID, OpenSearch generates one automatically, which can make it challenging to update the document at a later time. Signed-off-by: Cameron Durham --- CHANGELOG.md | 4 +++- api/types.d.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b0e7e40..b10674505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies ### Changed - Remove test artifacts from gh_pages workflow ([#335](https://github.com/opensearch-project/opensearch-js/issues/335)) +- Make fields in `BulkOperation` optional to match OpenSearch Bulk API requirements ([#378](https://github.com/opensearch-project/opensearch-js/pull/378)) + ### Deprecated ### Removed ### Fixed @@ -57,4 +59,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291)) [2.1]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.1.0 -[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.1...HEAD \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.1...HEAD diff --git a/api/types.d.ts b/api/types.d.ts index f0b0fe6e1..6628ce5da 100644 --- a/api/types.d.ts +++ b/api/types.d.ts @@ -40,12 +40,12 @@ export interface BulkIndexOperation extends BulkOperation { } export interface BulkIndexResponseItem extends BulkResponseItemBase { } export interface BulkOperation { - _id: Id; - _index: IndexName; - retry_on_conflict: integer; - routing: Routing; - version: VersionNumber; - version_type: VersionType; + _id?: Id; + _index?: IndexName; + retry_on_conflict?: integer; + routing?: Routing; + version?: VersionNumber; + version_type?: VersionType; } export interface BulkOperationContainer {