diff --git a/x-pack/plugins/search_indices/public/constants.ts b/x-pack/plugins/search_indices/public/constants.ts index bf9cf14a4ea17..fa5d7fde6d4c8 100644 --- a/x-pack/plugins/search_indices/public/constants.ts +++ b/x-pack/plugins/search_indices/public/constants.ts @@ -7,6 +7,7 @@ export enum QueryKeys { FetchIndex = 'fetchIndex', + FetchMapping = 'fetchMapping', FetchSearchIndicesStatus = 'fetchSearchIndicesStatus', FetchUserStartPrivileges = 'fetchUserStartPrivileges', SearchDocuments = 'searchDocuments', diff --git a/x-pack/plugins/search_indices/public/hooks/api/use_index_mappings.ts b/x-pack/plugins/search_indices/public/hooks/api/use_index_mappings.ts index 0e57e17465922..1d5a83aa920ed 100644 --- a/x-pack/plugins/search_indices/public/hooks/api/use_index_mappings.ts +++ b/x-pack/plugins/search_indices/public/hooks/api/use_index_mappings.ts @@ -8,12 +8,16 @@ import { useQuery } from '@tanstack/react-query'; import { useKibana } from '../use_kibana'; import { Mappings } from '../../types'; +import { QueryKeys } from '../../constants'; +const POLLING_INTERVAL = 15 * 1000; export const useIndexMapping = (indexName: string) => { const { http } = useKibana().services; - const queryKey = ['fetchMapping', indexName]; + const queryKey = [QueryKeys.FetchMapping, indexName]; const result = useQuery({ queryKey, + refetchInterval: POLLING_INTERVAL, + refetchIntervalInBackground: true, refetchOnWindowFocus: 'always', queryFn: () => http.fetch(`/api/index_management/mapping/${encodeURIComponent(indexName)}`),