@@ -41,7 +41,7 @@ export interface MsearchHelperOptions extends T.MsearchRequest {
41
41
42
42
export interface MsearchHelper extends Promise < void > {
43
43
stop : ( error ?: Error | null ) => void
44
- search : < TDocument = unknown > ( header : T . MsearchMultisearchHeader , body : T . MsearchMultisearchBody ) => Promise < MsearchHelperResponse < TDocument > >
44
+ search : < TDocument = unknown > ( header : T . MsearchMultisearchHeader , body : T . SearchSearchRequestBody ) => Promise < MsearchHelperResponse < TDocument > >
45
45
}
46
46
47
47
export interface MsearchHelperResponse < TDocument > {
@@ -362,7 +362,7 @@ export default class Helpers {
362
362
// TODO: support abort a single search?
363
363
// NOTE: the validation checks are synchronous and the callback/promise will
364
364
// be resolved in the same tick. We might want to fix this in the future.
365
- search < TDocument = unknown > ( header : T . MsearchMultisearchHeader , body : T . MsearchMultisearchBody ) : Promise < MsearchHelperResponse < TDocument > > {
365
+ search < TDocument = unknown > ( header : T . MsearchMultisearchHeader , body : T . SearchSearchRequestBody ) : Promise < MsearchHelperResponse < TDocument > > {
366
366
if ( stopReading ) {
367
367
const error = stopError === null
368
368
? new ConfigurationError ( 'The msearch processor has been stopped' )
@@ -397,7 +397,7 @@ export default class Helpers {
397
397
398
398
async function iterate ( ) : Promise < void > {
399
399
const { semaphore, finish } = buildSemaphore ( )
400
- const msearchBody : Array < T . MsearchMultisearchHeader | T . MsearchMultisearchBody > = [ ]
400
+ const msearchBody : Array < T . MsearchMultisearchHeader | T . SearchSearchRequestBody > = [ ]
401
401
const callbacks : any [ ] = [ ]
402
402
let loadedOperations = 0
403
403
timeoutRef = setTimeout ( onFlushTimeout , flushInterval ) // eslint-disable-line
@@ -490,7 +490,7 @@ export default class Helpers {
490
490
}
491
491
}
492
492
493
- function send ( msearchBody : Array < T . MsearchMultisearchHeader | T . MsearchMultisearchBody > , callbacks : any [ ] ) : void {
493
+ function send ( msearchBody : Array < T . MsearchMultisearchHeader | T . SearchSearchRequestBody > , callbacks : any [ ] ) : void {
494
494
/* istanbul ignore if */
495
495
if ( running > concurrency ) {
496
496
throw new Error ( 'Max concurrency reached' )
@@ -508,15 +508,15 @@ export default class Helpers {
508
508
}
509
509
}
510
510
511
- function msearchOperation ( msearchBody : Array < T . MsearchMultisearchHeader | T . MsearchMultisearchBody > , callbacks : any [ ] , done : ( ) => void ) : void {
511
+ function msearchOperation ( msearchBody : Array < T . MsearchMultisearchHeader | T . SearchSearchRequestBody > , callbacks : any [ ] , done : ( ) => void ) : void {
512
512
let retryCount = retries
513
513
514
514
// Instead of going full on async-await, which would make the code easier to read,
515
515
// we have decided to use callback style instead.
516
516
// This because every time we use async await, V8 will create multiple promises
517
517
// behind the scenes, making the code slightly slower.
518
518
tryMsearch ( msearchBody , callbacks , retrySearch )
519
- function retrySearch ( msearchBody : Array < T . MsearchMultisearchHeader | T . MsearchMultisearchBody > , callbacks : any [ ] ) : void {
519
+ function retrySearch ( msearchBody : Array < T . MsearchMultisearchHeader | T . SearchSearchRequestBody > , callbacks : any [ ] ) : void {
520
520
if ( msearchBody . length > 0 && retryCount > 0 ) {
521
521
retryCount -= 1
522
522
setTimeout ( tryMsearch , wait , msearchBody , callbacks , retrySearch )
@@ -528,7 +528,7 @@ export default class Helpers {
528
528
529
529
// This function never returns an error, if the msearch operation fails,
530
530
// the error is dispatched to all search executors.
531
- function tryMsearch ( msearchBody : Array < T . MsearchMultisearchHeader | T . MsearchMultisearchBody > , callbacks : any [ ] , done : ( msearchBody : Array < T . MsearchMultisearchHeader | T . MsearchMultisearchBody > , callbacks : any [ ] ) => void ) : void {
531
+ function tryMsearch ( msearchBody : Array < T . MsearchMultisearchHeader | T . SearchSearchRequestBody > , callbacks : any [ ] , done : ( msearchBody : Array < T . MsearchMultisearchHeader | T . SearchSearchRequestBody > , callbacks : any [ ] ) => void ) : void {
532
532
client . msearch ( Object . assign ( { } , msearchOptions , { body : msearchBody } ) , reqOptions as TransportRequestOptionsWithMeta )
533
533
. then ( results => {
534
534
const retryBody = [ ]
0 commit comments