Skip to content

Commit

Permalink
[Search][Fix] Index Details: poll mappings (elastic#197885)
Browse files Browse the repository at this point in the history
  • Loading branch information
TattdCodeMonkey authored Oct 25, 2024
1 parent 1065bbf commit de5ccde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/plugins/search_indices/public/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

export enum QueryKeys {
FetchIndex = 'fetchIndex',
FetchMapping = 'fetchMapping',
FetchSearchIndicesStatus = 'fetchSearchIndicesStatus',
FetchUserStartPrivileges = 'fetchUserStartPrivileges',
SearchDocuments = 'searchDocuments',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mappings, { body: { message: string; error: string } }>({
queryKey,
refetchInterval: POLLING_INTERVAL,
refetchIntervalInBackground: true,
refetchOnWindowFocus: 'always',
queryFn: () =>
http.fetch<Mappings>(`/api/index_management/mapping/${encodeURIComponent(indexName)}`),
Expand Down

0 comments on commit de5ccde

Please sign in to comment.