import * as Either from 'fp-ts/lib/Either' ; import * as TaskEither from 'fp-ts/lib/TaskEither' ; import { ElasticsearchClient } from '../../../elasticsearch' ; import { catchRetryableEsClientErrors , RetryableEsClientError , } from './catch_retryable_es_client_errors' ; internal export interface RefreshIndexParams { client : ElasticsearchClient ; targetIndex : string ; } /**
 * Wait for Elasticsearch to reindex all the changes.
 */ export const refreshIndex = ( { client , targetIndex , } ) : TaskEither . TaskEither < RetryableEsClientError , { refreshed : boolean ; } > => ( ) => { return client . indices . refresh ( { index : targetIndex , } ) . then ( ( ) => { return Either . right ( { refreshed : true } ) ; } ) . catch ( catchRetryableEsClientErrors ) ; } ;