[ML] DataFrame Analytics: filter out docs with no prediction data from results table (#54826) (#55077)
* filter out docs with no prediction data from results table * ensure bool.must exists in the cloned searchQuery * create must in bool query if not present
This commit is contained in:
parent
c0868965af
commit
677f030fb2
|
@ -67,6 +67,22 @@ import { ExplorationTitle } from './classification_exploration';
|
|||
const PAGE_SIZE_OPTIONS = [5, 10, 25, 50];
|
||||
|
||||
const MlInMemoryTableBasic = mlInMemoryTableBasicFactory<TableItem>();
|
||||
|
||||
const showingDocs = i18n.translate(
|
||||
'xpack.ml.dataframe.analytics.classificationExploration.documentsShownHelpText',
|
||||
{
|
||||
defaultMessage: 'Showing documents for which predictions exist',
|
||||
}
|
||||
);
|
||||
|
||||
const showingFirstDocs = i18n.translate(
|
||||
'xpack.ml.dataframe.analytics.classificationExploration.firstDocumentsShownHelpText',
|
||||
{
|
||||
defaultMessage: 'Showing first {searchSize} documents for which predictions exist',
|
||||
values: { searchSize: SEARCH_SIZE },
|
||||
}
|
||||
);
|
||||
|
||||
interface Props {
|
||||
jobConfig: DataFrameAnalyticsConfig;
|
||||
jobStatus: DATA_FRAME_TASK_STATE;
|
||||
|
@ -468,19 +484,11 @@ export const ResultsTable: FC<Props> = React.memo(
|
|||
)}
|
||||
{(columns.length > 0 || searchQuery !== defaultSearchQuery) && (
|
||||
<Fragment>
|
||||
{tableItems.length === SEARCH_SIZE && (
|
||||
<EuiFormRow
|
||||
helpText={i18n.translate(
|
||||
'xpack.ml.dataframe.analytics.classificationExploration.documentsShownHelpText',
|
||||
{
|
||||
defaultMessage: 'Showing first {searchSize} documents',
|
||||
values: { searchSize: SEARCH_SIZE },
|
||||
}
|
||||
)}
|
||||
>
|
||||
<Fragment />
|
||||
</EuiFormRow>
|
||||
)}
|
||||
<EuiFormRow
|
||||
helpText={tableItems.length === SEARCH_SIZE ? showingFirstDocs : showingDocs}
|
||||
>
|
||||
<Fragment />
|
||||
</EuiFormRow>
|
||||
<EuiSpacer />
|
||||
<MlInMemoryTableBasic
|
||||
allowNeutralSort={false}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import { SearchResponse } from 'elasticsearch';
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
import { SortDirection, SORT_DIRECTION } from '../../../../../components/ml_in_memory_table';
|
||||
|
||||
|
@ -19,8 +20,13 @@ import { ml } from '../../../../../services/ml_api_service';
|
|||
import { getNestedProperty } from '../../../../../util/object_utils';
|
||||
import { newJobCapsService } from '../../../../../services/new_job_capabilities_service';
|
||||
import { Field } from '../../../../../../../common/types/fields';
|
||||
import { LoadExploreDataArg } from '../../../../common/analytics';
|
||||
import { ES_FIELD_TYPES } from '../../../../../../../../../../../src/plugins/data/public';
|
||||
import {
|
||||
LoadExploreDataArg,
|
||||
defaultSearchQuery,
|
||||
ResultsSearchQuery,
|
||||
isResultsSearchBoolQuery,
|
||||
} from '../../../../common/analytics';
|
||||
|
||||
import {
|
||||
getDefaultFieldsFromJobCaps,
|
||||
|
@ -84,8 +90,33 @@ export const useExploreData = (
|
|||
|
||||
try {
|
||||
const resultsField = jobConfig.dest.results_field;
|
||||
const searchQueryClone: ResultsSearchQuery = cloneDeep(searchQuery);
|
||||
let query: ResultsSearchQuery;
|
||||
|
||||
if (JSON.stringify(searchQuery) === JSON.stringify(defaultSearchQuery)) {
|
||||
query = {
|
||||
exists: {
|
||||
field: resultsField,
|
||||
},
|
||||
};
|
||||
} else if (isResultsSearchBoolQuery(searchQueryClone)) {
|
||||
if (searchQueryClone.bool.must === undefined) {
|
||||
searchQueryClone.bool.must = [];
|
||||
}
|
||||
|
||||
searchQueryClone.bool.must.push({
|
||||
exists: {
|
||||
field: resultsField,
|
||||
},
|
||||
});
|
||||
|
||||
query = searchQueryClone;
|
||||
} else {
|
||||
query = searchQueryClone;
|
||||
}
|
||||
|
||||
const body: SearchQuery = {
|
||||
query: searchQuery,
|
||||
query,
|
||||
};
|
||||
|
||||
if (field !== undefined) {
|
||||
|
|
|
@ -68,6 +68,21 @@ const PAGE_SIZE_OPTIONS = [5, 10, 25, 50];
|
|||
|
||||
const MlInMemoryTableBasic = mlInMemoryTableBasicFactory<TableItem>();
|
||||
|
||||
const showingDocs = i18n.translate(
|
||||
'xpack.ml.dataframe.analytics.regressionExploration.documentsShownHelpText',
|
||||
{
|
||||
defaultMessage: 'Showing documents for which predictions exist',
|
||||
}
|
||||
);
|
||||
|
||||
const showingFirstDocs = i18n.translate(
|
||||
'xpack.ml.dataframe.analytics.regressionExploration.firstDocumentsShownHelpText',
|
||||
{
|
||||
defaultMessage: 'Showing first {searchSize} documents for which predictions exist',
|
||||
values: { searchSize: SEARCH_SIZE },
|
||||
}
|
||||
);
|
||||
|
||||
interface Props {
|
||||
jobConfig: DataFrameAnalyticsConfig;
|
||||
jobStatus: DATA_FRAME_TASK_STATE;
|
||||
|
@ -468,19 +483,12 @@ export const ResultsTable: FC<Props> = React.memo(
|
|||
)}
|
||||
{(columns.length > 0 || searchQuery !== defaultSearchQuery) && (
|
||||
<Fragment>
|
||||
{tableItems.length === SEARCH_SIZE && (
|
||||
<EuiFormRow
|
||||
helpText={i18n.translate(
|
||||
'xpack.ml.dataframe.analytics.regressionExploration.documentsShownHelpText',
|
||||
{
|
||||
defaultMessage: 'Showing first {searchSize} documents',
|
||||
values: { searchSize: SEARCH_SIZE },
|
||||
}
|
||||
)}
|
||||
>
|
||||
<Fragment />
|
||||
</EuiFormRow>
|
||||
)}
|
||||
<EuiFormRow
|
||||
helpText={tableItems.length === SEARCH_SIZE ? showingFirstDocs : showingDocs}
|
||||
>
|
||||
<Fragment />
|
||||
</EuiFormRow>
|
||||
|
||||
<EuiSpacer />
|
||||
<MlInMemoryTableBasic
|
||||
allowNeutralSort={false}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import { SearchResponse } from 'elasticsearch';
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
import { SortDirection, SORT_DIRECTION } from '../../../../../components/ml_in_memory_table';
|
||||
|
||||
|
@ -24,8 +25,13 @@ import {
|
|||
SearchQuery,
|
||||
} from '../../../../common';
|
||||
import { Field } from '../../../../../../../common/types/fields';
|
||||
import { LoadExploreDataArg } from '../../../../common/analytics';
|
||||
import { ES_FIELD_TYPES } from '../../../../../../../../../../../src/plugins/data/public';
|
||||
import {
|
||||
LoadExploreDataArg,
|
||||
defaultSearchQuery,
|
||||
ResultsSearchQuery,
|
||||
isResultsSearchBoolQuery,
|
||||
} from '../../../../common/analytics';
|
||||
|
||||
export type TableItem = Record<string, any>;
|
||||
|
||||
|
@ -79,8 +85,32 @@ export const useExploreData = (
|
|||
|
||||
try {
|
||||
const resultsField = jobConfig.dest.results_field;
|
||||
const searchQueryClone: ResultsSearchQuery = cloneDeep(searchQuery);
|
||||
let query: ResultsSearchQuery;
|
||||
|
||||
if (JSON.stringify(searchQuery) === JSON.stringify(defaultSearchQuery)) {
|
||||
query = {
|
||||
exists: {
|
||||
field: resultsField,
|
||||
},
|
||||
};
|
||||
} else if (isResultsSearchBoolQuery(searchQueryClone)) {
|
||||
if (searchQueryClone.bool.must === undefined) {
|
||||
searchQueryClone.bool.must = [];
|
||||
}
|
||||
|
||||
searchQueryClone.bool.must.push({
|
||||
exists: {
|
||||
field: resultsField,
|
||||
},
|
||||
});
|
||||
|
||||
query = searchQueryClone;
|
||||
} else {
|
||||
query = searchQueryClone;
|
||||
}
|
||||
const body: SearchQuery = {
|
||||
query: searchQuery,
|
||||
query,
|
||||
};
|
||||
|
||||
if (field !== undefined) {
|
||||
|
|
Loading…
Reference in a new issue