@@ -56,7 +56,7 @@ import { useDataVisualizerKibana } from '../../../kibana_context';
5656import { FieldCountPanel } from '../../../common/components/field_count_panel' ;
5757import { DocumentCountContent } from '../../../common/components/document_count_content' ;
5858import { DataLoader } from '../../data_loader/data_loader' ;
59- import { JOB_FIELD_TYPES } from '../../../../../common' ;
59+ import { JOB_FIELD_TYPES , OMIT_FIELDS } from '../../../../../common' ;
6060import { useTimefilter } from '../../hooks/use_time_filter' ;
6161import { kbnTypeToJobType } from '../../../common/util/field_types_utils' ;
6262import { SearchPanel } from '../search_panel' ;
@@ -204,18 +204,21 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
204204 }
205205 } , [ currentIndexPattern , toasts ] ) ;
206206
207- // Obtain the list of non metric field types which appear in the index pattern.
208- let indexedFieldTypes : JobFieldType [ ] = [ ] ;
209207 const indexPatternFields : IndexPatternField [ ] = currentIndexPattern . fields ;
210- indexPatternFields . forEach ( ( field ) => {
211- if ( field . scripted !== true ) {
212- const dataVisualizerType : JobFieldType | undefined = kbnTypeToJobType ( field ) ;
213- if ( dataVisualizerType !== undefined && ! indexedFieldTypes . includes ( dataVisualizerType ) ) {
214- indexedFieldTypes . push ( dataVisualizerType ) ;
208+
209+ const fieldTypes = useMemo ( ( ) => {
210+ // Obtain the list of non metric field types which appear in the index pattern.
211+ const indexedFieldTypes : JobFieldType [ ] = [ ] ;
212+ indexPatternFields . forEach ( ( field ) => {
213+ if ( ! OMIT_FIELDS . includes ( field . name ) && field . scripted !== true ) {
214+ const dataVisualizerType : JobFieldType | undefined = kbnTypeToJobType ( field ) ;
215+ if ( dataVisualizerType !== undefined && ! indexedFieldTypes . includes ( dataVisualizerType ) ) {
216+ indexedFieldTypes . push ( dataVisualizerType ) ;
217+ }
215218 }
216- }
217- } ) ;
218- indexedFieldTypes = indexedFieldTypes . sort ( ) ;
219+ } ) ;
220+ return indexedFieldTypes . sort ( ) ;
221+ } , [ indexPatternFields ] ) ;
219222
220223 const defaults = getDefaultPageState ( ) ;
221224
@@ -859,7 +862,7 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
859862 samplerShardSize = { samplerShardSize }
860863 setSamplerShardSize = { setSamplerShardSize }
861864 overallStats = { overallStats }
862- indexedFieldTypes = { indexedFieldTypes }
865+ indexedFieldTypes = { fieldTypes }
863866 setVisibleFieldTypes = { setVisibleFieldTypes }
864867 visibleFieldTypes = { visibleFieldTypes }
865868 visibleFieldNames = { visibleFieldNames }
0 commit comments