mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Added an error for when there are no source fields available.
Loaded a small set of default fields if we know its a connector index.
(cherry picked from commit c19ccdb96c
)
# Conflicts:
# x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/configure_pipeline.tsx
# x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/ml_inference_logic.ts
This commit is contained in:
parent
3378f70cc9
commit
b6ddeba197
2 changed files with 42 additions and 3 deletions
|
@ -22,11 +22,29 @@ import {
|
|||
} from '@elastic/eui';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
|
||||
import { docLinks } from '../../../../../shared/doc_links';
|
||||
|
||||
import { MLInferenceLogic } from './ml_inference_logic';
|
||||
|
||||
const NoSourceFieldsError: React.FC = () => (
|
||||
<FormattedMessage
|
||||
id="xpack.enterpriseSearch.content.indices.pipelines.addInferencePipelineModal.steps.configure.sourceField.error"
|
||||
defaultMessage="Selecting a source field is required for pipeline configuration, but this index does not have a field mapping. {learnMore}"
|
||||
values={{
|
||||
learnMore: (
|
||||
<EuiLink href={docLinks.elasticsearchMapping} target="_blank" color="danger">
|
||||
{i18n.translate(
|
||||
'xpack.enterpriseSearch.content.indices.pipelines.addInferencePipelineModal.steps.configure.sourceField.error.docLink',
|
||||
{ defaultMessage: 'Learn more about field mapping' }
|
||||
)}
|
||||
</EuiLink>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
export const ConfigurePipeline: React.FC = () => {
|
||||
const {
|
||||
addInferencePipelineModal: { configuration },
|
||||
|
@ -38,6 +56,7 @@ export const ConfigurePipeline: React.FC = () => {
|
|||
|
||||
const { destinationField, modelID, pipelineName, sourceField } = configuration;
|
||||
const models = supportedMLModels ?? [];
|
||||
const emptySourceFields = (sourceFields?.length ?? 0) === 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -142,6 +161,8 @@ export const ConfigurePipeline: React.FC = () => {
|
|||
defaultMessage: 'Source field',
|
||||
}
|
||||
)}
|
||||
error={emptySourceFields && <NoSourceFieldsError />}
|
||||
isInvalid={emptySourceFields}
|
||||
>
|
||||
<EuiSelect
|
||||
value={sourceField}
|
||||
|
|
|
@ -16,11 +16,16 @@ import { HttpError, Status } from '../../../../../../../common/types/api';
|
|||
import { generateEncodedPath } from '../../../../../shared/encode_path_params';
|
||||
import { getErrorsFromHttpResponse } from '../../../../../shared/flash_messages/handle_api_errors';
|
||||
import { KibanaLogic } from '../../../../../shared/kibana';
|
||||
import {
|
||||
FetchIndexApiLogic,
|
||||
FetchIndexApiResponse,
|
||||
} from '../../../../api/index/fetch_index_api_logic';
|
||||
import { MappingsApiLogic } from '../../../../api/mappings/mappings_logic';
|
||||
import { CreateMlInferencePipelineApiLogic } from '../../../../api/ml_models/create_ml_inference_pipeline';
|
||||
import { MLModelsApiLogic } from '../../../../api/ml_models/ml_models_logic';
|
||||
|
||||
import { SEARCH_INDEX_TAB_PATH } from '../../../../routes';
|
||||
import { isConnectorIndex } from '../../../../utils/indices';
|
||||
import { SearchIndexTabId } from '../../search_index';
|
||||
|
||||
import { AddInferencePipelineFormErrors, InferencePipelineConfiguration } from './types';
|
||||
|
@ -38,6 +43,7 @@ export const EMPTY_PIPELINE_CONFIGURATION: InferencePipelineConfiguration = {
|
|||
};
|
||||
|
||||
const API_REQUEST_COMPLETE_STATUSES = [Status.SUCCESS, Status.ERROR];
|
||||
const DEFAULT_CONNECTOR_FIELDS = ['body', 'title', 'id', 'type', 'url'];
|
||||
|
||||
interface MLInferenceProcessorsActions {
|
||||
clearFormErrors: () => void;
|
||||
|
@ -68,6 +74,7 @@ interface MLInferenceProcessorsValues {
|
|||
addInferencePipelineModal: AddInferencePipelineModal;
|
||||
createErrors: string[];
|
||||
formErrors: AddInferencePipelineFormErrors;
|
||||
index: FetchIndexApiResponse;
|
||||
isLoading: boolean;
|
||||
mappingData: typeof MappingsApiLogic.values.data;
|
||||
mappingStatus: Status;
|
||||
|
@ -104,6 +111,8 @@ export const MLInferenceLogic = kea<
|
|||
],
|
||||
],
|
||||
values: [
|
||||
FetchIndexApiLogic,
|
||||
['data as index'],
|
||||
MappingsApiLogic,
|
||||
['data as mappingData', 'status as mappingStatus'],
|
||||
MLModelsApiLogic,
|
||||
|
@ -187,10 +196,19 @@ export const MLInferenceLogic = kea<
|
|||
!API_REQUEST_COMPLETE_STATUSES.includes(mappingStatus),
|
||||
],
|
||||
sourceFields: [
|
||||
() => [selectors.mappingStatus, selectors.mappingData],
|
||||
(status: Status, mapping: IndicesGetMappingIndexMappingRecord) => {
|
||||
() => [selectors.mappingStatus, selectors.mappingData, selectors.index],
|
||||
(
|
||||
status: Status,
|
||||
mapping: IndicesGetMappingIndexMappingRecord,
|
||||
index: FetchIndexApiResponse
|
||||
) => {
|
||||
if (status !== Status.SUCCESS) return;
|
||||
if (mapping?.mappings?.properties === undefined) return [];
|
||||
if (mapping?.mappings?.properties === undefined) {
|
||||
if (isConnectorIndex(index)) {
|
||||
return DEFAULT_CONNECTOR_FIELDS;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
return Object.entries(mapping.mappings.properties)
|
||||
.reduce((fields, [key, value]) => {
|
||||
if (value.type === 'text' || value.type === 'keyword') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue