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' ; import { BATCH_SIZE } from './constants' ; export interface UpdateByQueryResponse { taskId : string ; } remarks export const pickupUpdatedMappings = ( client , index ) : TaskEither . TaskEither < RetryableEsClientError , UpdateByQueryResponse > => ( ) => { return client . updateByQuery ( { conflicts : 'proceed' , allow_no_indices : false , index , scroll_size : BATCH_SIZE , refresh : true , wait_for_completion : false , } ) . then ( ( { body : { task : taskId } } ) => { return Either . right ( { taskId : String ( taskId ! ) } ) ; } ) . catch ( catchRetryableEsClientErrors ) ; } ;