mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Auto selecting categorization field (#54365)
* [ML] Auto selecting categorization field * updating translations * reverting unrelated translation changes
This commit is contained in:
parent
9ee9f3d038
commit
cda91cf0cb
4 changed files with 32 additions and 13 deletions
|
@ -297,10 +297,10 @@ export function getJobCreatorTitle(jobCreator: JobCreatorType) {
|
|||
return i18n.translate('xpack.ml.newJob.wizard.jobCreatorTitle.advanced', {
|
||||
defaultMessage: 'Advanced',
|
||||
});
|
||||
// case JOB_TYPE.CATEGORIZATION:
|
||||
// return i18n.translate('xpack.ml.newJob.wizard.jobCreatorTitle.categorization', {
|
||||
// defaultMessage: 'Categorization',
|
||||
// });
|
||||
case JOB_TYPE.CATEGORIZATION:
|
||||
return i18n.translate('xpack.ml.newJob.wizard.jobCreatorTitle.categorization', {
|
||||
defaultMessage: 'Categorization',
|
||||
});
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -10,19 +10,20 @@ import { CategorizationFieldSelect } from './categorization_field_select';
|
|||
import { JobCreatorContext } from '../../../job_creator_context';
|
||||
import { newJobCapsService } from '../../../../../../../services/new_job_capabilities_service';
|
||||
import {
|
||||
MultiMetricJobCreator,
|
||||
PopulationJobCreator,
|
||||
AdvancedJobCreator,
|
||||
CategorizationJobCreator,
|
||||
isCategorizationJobCreator,
|
||||
} from '../../../../../common/job_creator';
|
||||
import { Description } from './description';
|
||||
|
||||
export const CategorizationField: FC = () => {
|
||||
const { jobCreator: jc, jobCreatorUpdate, jobCreatorUpdated } = useContext(JobCreatorContext);
|
||||
const jobCreator = jc as MultiMetricJobCreator | PopulationJobCreator | AdvancedJobCreator;
|
||||
const jobCreator = jc as AdvancedJobCreator | CategorizationJobCreator;
|
||||
const { catFields } = newJobCapsService;
|
||||
const [categorizationFieldName, setCategorizationFieldName] = useState(
|
||||
jobCreator.categorizationFieldName
|
||||
);
|
||||
const isCategorizationJob = isCategorizationJobCreator(jobCreator);
|
||||
|
||||
useEffect(() => {
|
||||
if (jobCreator.categorizationFieldName !== categorizationFieldName) {
|
||||
|
@ -36,7 +37,7 @@ export const CategorizationField: FC = () => {
|
|||
}, [jobCreatorUpdated]);
|
||||
|
||||
return (
|
||||
<Description>
|
||||
<Description isOptional={isCategorizationJob === false}>
|
||||
<CategorizationFieldSelect
|
||||
fields={catFields}
|
||||
changeHandler={setCategorizationFieldName}
|
||||
|
|
|
@ -9,7 +9,10 @@ import { i18n } from '@kbn/i18n';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiDescribedFormGroup, EuiFormRow } from '@elastic/eui';
|
||||
|
||||
export const Description: FC = memo(({ children }) => {
|
||||
interface Props {
|
||||
isOptional: boolean;
|
||||
}
|
||||
export const Description: FC<Props> = memo(({ children, isOptional }) => {
|
||||
const title = i18n.translate('xpack.ml.newJob.wizard.pickFieldsStep.categorizationField.title', {
|
||||
defaultMessage: 'Categorization field',
|
||||
});
|
||||
|
@ -18,10 +21,19 @@ export const Description: FC = memo(({ children }) => {
|
|||
idAria="description"
|
||||
title={<h3>{title}</h3>}
|
||||
description={
|
||||
<FormattedMessage
|
||||
id="xpack.ml.newJob.wizard.pickFieldsStep.categorizationField.description"
|
||||
defaultMessage="Optional, for use if analyzing unstructured log data. Using text data types is recommended."
|
||||
/>
|
||||
<>
|
||||
{isOptional ? (
|
||||
<FormattedMessage
|
||||
id="xpack.ml.newJob.wizard.pickFieldsStep.categorizationFieldOptional.description"
|
||||
defaultMessage="Optional, for use if analyzing unstructured log data. Using text data types is recommended."
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.ml.newJob.wizard.pickFieldsStep.categorizationField.description"
|
||||
defaultMessage="Specifies which field will be categorized. Using text data types is recommended."
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<EuiFormRow label={title} describedByIds={['description']}>
|
||||
|
|
|
@ -133,6 +133,12 @@ export const Page: FC<PageProps> = ({ existingJobsAndGroups, jobType }) => {
|
|||
// auto set the time range if creating a new advanced job
|
||||
autoSetTimeRange = isAdvancedJobCreator(jobCreator);
|
||||
initCategorizationSettings();
|
||||
if (isCategorizationJobCreator(jobCreator)) {
|
||||
const { catFields } = newJobCapsService;
|
||||
if (catFields.length === 1) {
|
||||
jobCreator.categorizationFieldName = catFields[0].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (autoSetTimeRange && isAdvancedJobCreator(jobCreator)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue