From 5c03c8f0863df7bc6072d8fba1f0ed3681afc901 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Mon, 9 Jan 2023 11:12:35 +0800 Subject: [PATCH] support reindex unique documents (#546) Signed-off-by: Hailong Cui Signed-off-by: Hailong Cui --- .../ReindexAdvancedOptions.test.tsx | 8 ++ .../ReindexAdvancedOptions.tsx | 29 ++++- .../ReindexAdvancedOptions.test.tsx.snap | 116 +++++++++++++++++- .../Reindex/container/Reindex/Reindex.tsx | 36 ++++-- .../__snapshots__/Reindex.test.tsx.snap | 45 +++---- 5 files changed, 198 insertions(+), 36 deletions(-) diff --git a/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.test.tsx b/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.test.tsx index a89a6762a..b0e5e0361 100644 --- a/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.test.tsx +++ b/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.test.tsx @@ -21,6 +21,8 @@ describe(" spec", () => { ignoreConflicts={true} onIgnoreConflictsChange={() => {}} getAllPipelines={async () => [{ label: "pipeline" }]} + reindexUniqueDocuments={true} + onReindexUniqueDocumentsChange={() => {}} /> ); @@ -41,6 +43,8 @@ describe(" spec", () => { ignoreConflicts={false} onIgnoreConflictsChange={() => {}} getAllPipelines={async () => [{ label: "pipeline" }]} + reindexUniqueDocuments={true} + onReindexUniqueDocumentsChange={() => {}} /> ); @@ -61,6 +65,8 @@ describe(" spec", () => { ignoreConflicts={false} onIgnoreConflictsChange={() => {}} getAllPipelines={async () => Promise.reject("service not available")} + reindexUniqueDocuments={true} + onReindexUniqueDocumentsChange={() => {}} /> ); @@ -82,6 +88,8 @@ describe(" spec", () => { ignoreConflicts={false} onIgnoreConflictsChange={() => {}} getAllPipelines={getPipeline} + reindexUniqueDocuments={true} + onReindexUniqueDocumentsChange={() => {}} /> ); diff --git a/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.tsx b/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.tsx index cc6ee81fe..d009b095f 100644 --- a/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.tsx +++ b/public/pages/Reindex/components/ReindexAdvancedOptions/ReindexAdvancedOptions.tsx @@ -18,6 +18,8 @@ interface ReindexOptionsProps { getAllPipelines: () => Promise; ignoreConflicts: boolean; onIgnoreConflictsChange: (val: ChangeEvent) => void; + reindexUniqueDocuments: boolean; + onReindexUniqueDocumentsChange: (val: ChangeEvent) => void; } const ReindexAdvancedOptions = (props: ReindexOptionsProps) => { @@ -34,6 +36,8 @@ const ReindexAdvancedOptions = (props: ReindexOptionsProps) => { getAllPipelines, ignoreConflicts, onIgnoreConflictsChange, + reindexUniqueDocuments, + onReindexUniqueDocumentsChange, } = props; const sliceEnabled = slices !== undefined; @@ -52,11 +56,32 @@ const ReindexAdvancedOptions = (props: ReindexOptionsProps) => { return (
+ + You can choose to copy only the documents that do not exist in the destination index. By default, OpenSearch will copy all + documents from the source index.{" "} + + Learn more. + + + } + > + + + + - Instead of failing the reindexing operation, ignore any version conflicts during reindexing. + Instead of failing the reindexing operation, ignore any version conflicts during reindexing.{" "} Learn more. @@ -143,7 +168,7 @@ const ReindexAdvancedOptions = (props: ReindexOptionsProps) => { } helpText={ <> - Select an ingest pipeline if you need to transform documents before writing data to the destination index. + Select an ingest pipeline to transform documents before writing data to the destination.{" "} Learn more. diff --git a/public/pages/Reindex/components/ReindexAdvancedOptions/__snapshots__/ReindexAdvancedOptions.test.tsx.snap b/public/pages/Reindex/components/ReindexAdvancedOptions/__snapshots__/ReindexAdvancedOptions.test.tsx.snap index c51ea50ba..40aa69056 100644 --- a/public/pages/Reindex/components/ReindexAdvancedOptions/__snapshots__/ReindexAdvancedOptions.test.tsx.snap +++ b/public/pages/Reindex/components/ReindexAdvancedOptions/__snapshots__/ReindexAdvancedOptions.test.tsx.snap @@ -8,6 +8,60 @@ Object {
+
+
+ +
+
+
+ You can choose to copy only the documents that do not exist in the destination index. By default, OpenSearch will copy all documents from the source index. + + +
+
+ +
+ +
+
+
+
Instead of failing the reindexing operation, ignore any version conflicts during reindexing. + +
+
+ +
+ +
+
+
+
Instead of failing the reindexing operation, ignore any version conflicts during reindexing. +
+ } + > + <> + ); // expand data streams and aliases @@ -632,6 +644,8 @@ export default class Reindex extends Component { onSelectedPipelinesChange={this.onPipelineChange} ignoreConflicts={ignoreConflicts} onIgnoreConflictsChange={this.onIgnoreConflictsChange} + reindexUniqueDocuments={reindexUniqueDocuments} + onReindexUniqueDocumentsChange={this.onReindexUniqueDocuments} /> )} diff --git a/public/pages/Reindex/container/Reindex/__snapshots__/Reindex.test.tsx.snap b/public/pages/Reindex/container/Reindex/__snapshots__/Reindex.test.tsx.snap index 6c1940b57..c8e740d82 100644 --- a/public/pages/Reindex/container/Reindex/__snapshots__/Reindex.test.tsx.snap +++ b/public/pages/Reindex/container/Reindex/__snapshots__/Reindex.test.tsx.snap @@ -10,32 +10,35 @@ exports[` spec renders the component 1`] = ` Reindex