Skip to content

Commit

Permalink
Add existing indices as a source data option; improve config autofill…
Browse files Browse the repository at this point in the history
…ing (opensearch-project#346)

* Add options; auto-populate sample docs on index selection

Signed-off-by: Tyler Ohlsen <[email protected]>

* onboard getmappings api; set default mappings and ml processor configs optionally

Signed-off-by: Tyler Ohlsen <[email protected]>

* clear out some config on manual or uploaded doc input changes

Signed-off-by: Tyler Ohlsen <[email protected]>

* change default index name for custom

Signed-off-by: Tyler Ohlsen <[email protected]>

* revert overwriting of index mappings

Signed-off-by: Tyler Ohlsen <[email protected]>

* revert vector field overriding

Signed-off-by: Tyler Ohlsen <[email protected]>

* Move vector search check

Signed-off-by: Tyler Ohlsen <[email protected]>

---------

Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler authored Sep 5, 2024
1 parent bfeb79c commit 6408c43
Show file tree
Hide file tree
Showing 16 changed files with 373 additions and 66 deletions.
1 change: 1 addition & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const BASE_NODE_API_PATH = '/api/flow_framework';
// OpenSearch node APIs
export const BASE_OPENSEARCH_NODE_API_PATH = `${BASE_NODE_API_PATH}/opensearch`;
export const CAT_INDICES_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/catIndices`;
export const GET_MAPPINGS_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/mappings`;
export const SEARCH_INDEX_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/search`;
export const INGEST_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/ingest`;
export const BULK_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/bulk`;
Expand Down
4 changes: 2 additions & 2 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ export type NormalizationProcessor = SearchProcessor & {
};

export type IndexConfiguration = {
settings: {};
settings: { [key: string]: any };
mappings: IndexMappings;
};

export type IndexMappings = {
properties: {};
properties: { [key: string]: any };
};

export type TemplateNode = {
Expand Down
13 changes: 12 additions & 1 deletion common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import moment from 'moment';
import { DATE_FORMAT_PATTERN } from './';
import { DATE_FORMAT_PATTERN, WORKFLOW_TYPE, Workflow } from './';
import { isEmpty } from 'lodash';

export function toFormattedDate(timestampMillis: number): String {
Expand Down Expand Up @@ -39,3 +39,14 @@ export function getCharacterLimitedString(
export function customStringify(jsonObj: {}): string {
return JSON.stringify(jsonObj, undefined, 2);
}

export function isVectorSearchUseCase(workflow: Workflow | undefined): boolean {
return (
workflow?.ui_metadata?.type !== undefined &&
[
WORKFLOW_TYPE.HYBRID_SEARCH,
WORKFLOW_TYPE.MULTIMODAL_SEARCH,
WORKFLOW_TYPE.SEMANTIC_SEARCH,
].includes(workflow?.ui_metadata?.type)
);
}
8 changes: 2 additions & 6 deletions public/pages/workflow_detail/resizable_workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import React, { useRef, useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { Form, Formik } from 'formik';
import * as yup from 'yup';
import {
Expand All @@ -21,6 +20,7 @@ import {
WorkflowConfig,
WorkflowFormValues,
WorkflowSchema,
customStringify,
} from '../../../common';
import {
isValidUiWorkflow,
Expand Down Expand Up @@ -286,11 +286,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
</EuiFlexItem>
<EuiFlexItem grow={7}>
<EuiCodeBlock language="json" fontSize="m" isCopyable={false}>
{JSON.stringify(
reduceToTemplate(props.workflow as Workflow),
undefined,
2
)}
{customStringify(reduceToTemplate(props.workflow as Workflow))}
</EuiCodeBlock>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
3 changes: 3 additions & 0 deletions public/pages/workflow_detail/workflow_detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getCore } from '../../services';
import { WorkflowDetailHeader } from './components';
import {
AppState,
catIndices,
getWorkflow,
searchModels,
useAppDispatch,
Expand Down Expand Up @@ -101,9 +102,11 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
// On initial load:
// - fetch workflow
// - fetch available models as their IDs may be used when building flows
// - fetch all indices
useEffect(() => {
dispatch(getWorkflow({ workflowId, dataSourceId }));
dispatch(searchModels({ apiBody: FETCH_ALL_QUERY, dataSourceId }));
dispatch(catIndices({ pattern: '*,-.*', dataSourceId }));
}, []);

return errorMessage.includes(ERROR_GETTING_WORKFLOW_MSG) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
import { SourceData } from './source_data';
import { EnrichData } from './enrich_data';
import { IngestData } from './ingest_data';
import { WorkflowConfig } from '../../../../../common';
import { Workflow, WorkflowConfig } from '../../../../../common';

interface IngestInputsProps {
setIngestDocs: (docs: string) => void;
uiConfig: WorkflowConfig;
setUiConfig: (uiConfig: WorkflowConfig) => void;
workflow: Workflow | undefined;
}

/**
Expand All @@ -23,7 +24,11 @@ export function IngestInputs(props: IngestInputsProps) {
return (
<EuiFlexGroup direction="column">
<EuiFlexItem grow={false}>
<SourceData setIngestDocs={props.setIngestDocs} />
<SourceData
workflow={props.workflow}
uiConfig={props.uiConfig}
setIngestDocs={props.setIngestDocs}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiHorizontalRule margin="none" />
Expand Down
Loading

0 comments on commit 6408c43

Please sign in to comment.