Skip to content

Commit 7dfc375

Browse files
Add existing indices as a source data option; improve config autofilling (#346) (#347)
--------- Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> (cherry picked from commit 6408c43) Co-authored-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent cc510e6 commit 7dfc375

16 files changed

+373
-66
lines changed

common/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const BASE_NODE_API_PATH = '/api/flow_framework';
3434
// OpenSearch node APIs
3535
export const BASE_OPENSEARCH_NODE_API_PATH = `${BASE_NODE_API_PATH}/opensearch`;
3636
export const CAT_INDICES_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/catIndices`;
37+
export const GET_MAPPINGS_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/mappings`;
3738
export const SEARCH_INDEX_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/search`;
3839
export const INGEST_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/ingest`;
3940
export const BULK_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/bulk`;

common/interfaces.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ export type NormalizationProcessor = SearchProcessor & {
238238
};
239239

240240
export type IndexConfiguration = {
241-
settings: {};
241+
settings: { [key: string]: any };
242242
mappings: IndexMappings;
243243
};
244244

245245
export type IndexMappings = {
246-
properties: {};
246+
properties: { [key: string]: any };
247247
};
248248

249249
export type TemplateNode = {

common/utils.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import moment from 'moment';
7-
import { DATE_FORMAT_PATTERN } from './';
7+
import { DATE_FORMAT_PATTERN, WORKFLOW_TYPE, Workflow } from './';
88
import { isEmpty } from 'lodash';
99

1010
export function toFormattedDate(timestampMillis: number): String {
@@ -39,3 +39,14 @@ export function getCharacterLimitedString(
3939
export function customStringify(jsonObj: {}): string {
4040
return JSON.stringify(jsonObj, undefined, 2);
4141
}
42+
43+
export function isVectorSearchUseCase(workflow: Workflow | undefined): boolean {
44+
return (
45+
workflow?.ui_metadata?.type !== undefined &&
46+
[
47+
WORKFLOW_TYPE.HYBRID_SEARCH,
48+
WORKFLOW_TYPE.MULTIMODAL_SEARCH,
49+
WORKFLOW_TYPE.SEMANTIC_SEARCH,
50+
].includes(workflow?.ui_metadata?.type)
51+
);
52+
}

public/pages/workflow_detail/resizable_workspace.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import React, { useRef, useState, useEffect } from 'react';
7-
import { useSelector } from 'react-redux';
87
import { Form, Formik } from 'formik';
98
import * as yup from 'yup';
109
import {
@@ -21,6 +20,7 @@ import {
2120
WorkflowConfig,
2221
WorkflowFormValues,
2322
WorkflowSchema,
23+
customStringify,
2424
} from '../../../common';
2525
import {
2626
isValidUiWorkflow,
@@ -286,11 +286,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
286286
</EuiFlexItem>
287287
<EuiFlexItem grow={7}>
288288
<EuiCodeBlock language="json" fontSize="m" isCopyable={false}>
289-
{JSON.stringify(
290-
reduceToTemplate(props.workflow as Workflow),
291-
undefined,
292-
2
293-
)}
289+
{customStringify(reduceToTemplate(props.workflow as Workflow))}
294290
</EuiCodeBlock>
295291
</EuiFlexItem>
296292
</EuiFlexGroup>

public/pages/workflow_detail/workflow_detail.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { getCore } from '../../services';
2121
import { WorkflowDetailHeader } from './components';
2222
import {
2323
AppState,
24+
catIndices,
2425
getWorkflow,
2526
searchModels,
2627
useAppDispatch,
@@ -101,9 +102,11 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
101102
// On initial load:
102103
// - fetch workflow
103104
// - fetch available models as their IDs may be used when building flows
105+
// - fetch all indices
104106
useEffect(() => {
105107
dispatch(getWorkflow({ workflowId, dataSourceId }));
106108
dispatch(searchModels({ apiBody: FETCH_ALL_QUERY, dataSourceId }));
109+
dispatch(catIndices({ pattern: '*,-.*', dataSourceId }));
107110
}, []);
108111

109112
return errorMessage.includes(ERROR_GETTING_WORKFLOW_MSG) ||

public/pages/workflow_detail/workflow_inputs/ingest_inputs/ingest_inputs.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
88
import { SourceData } from './source_data';
99
import { EnrichData } from './enrich_data';
1010
import { IngestData } from './ingest_data';
11-
import { WorkflowConfig } from '../../../../../common';
11+
import { Workflow, WorkflowConfig } from '../../../../../common';
1212

1313
interface IngestInputsProps {
1414
setIngestDocs: (docs: string) => void;
1515
uiConfig: WorkflowConfig;
1616
setUiConfig: (uiConfig: WorkflowConfig) => void;
17+
workflow: Workflow | undefined;
1718
}
1819

1920
/**
@@ -23,7 +24,11 @@ export function IngestInputs(props: IngestInputsProps) {
2324
return (
2425
<EuiFlexGroup direction="column">
2526
<EuiFlexItem grow={false}>
26-
<SourceData setIngestDocs={props.setIngestDocs} />
27+
<SourceData
28+
workflow={props.workflow}
29+
uiConfig={props.uiConfig}
30+
setIngestDocs={props.setIngestDocs}
31+
/>
2732
</EuiFlexItem>
2833
<EuiFlexItem grow={false}>
2934
<EuiHorizontalRule margin="none" />

0 commit comments

Comments
 (0)