@@ -65,19 +65,24 @@ export default class Fleet {
6565 return await this . transport . request ( { path, method, querystring, body } , options )
6666 }
6767
68- async msearch ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptionsWithOutMeta ) : Promise < T . TODO >
69- async msearch ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptionsWithMeta ) : Promise < TransportResult < T . TODO , unknown > >
70- async msearch ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptions ) : Promise < T . TODO >
71- async msearch ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptions ) : Promise < any > {
68+ async msearch < TDocument = unknown > ( this : That , params : T . FleetMsearchRequest | TB . FleetMsearchRequest , options ?: TransportRequestOptionsWithOutMeta ) : Promise < T . FleetMsearchResponse < TDocument > >
69+ async msearch < TDocument = unknown > ( this : That , params : T . FleetMsearchRequest | TB . FleetMsearchRequest , options ?: TransportRequestOptionsWithMeta ) : Promise < TransportResult < T . FleetMsearchResponse < TDocument > , unknown > >
70+ async msearch < TDocument = unknown > ( this : That , params : T . FleetMsearchRequest | TB . FleetMsearchRequest , options ?: TransportRequestOptions ) : Promise < T . FleetMsearchResponse < TDocument > >
71+ async msearch < TDocument = unknown > ( this : That , params : T . FleetMsearchRequest | TB . FleetMsearchRequest , options ?: TransportRequestOptions ) : Promise < any > {
7272 const acceptedPath : string [ ] = [ 'index' ]
73+ const acceptedBody : string [ ] = [ 'searches' ]
7374 const querystring : Record < string , any > = { }
74- const body = undefined
75+ // @ts -expect-error
76+ let body : any = params . body ?? undefined
7577
76- params = params ?? { }
7778 for ( const key in params ) {
78- if ( acceptedPath . includes ( key ) ) {
79+ if ( acceptedBody . includes ( key ) ) {
80+ // @ts -expect-error
81+ body = params [ key ]
82+ } else if ( acceptedPath . includes ( key ) ) {
7983 continue
8084 } else if ( key !== 'body' ) {
85+ // @ts -expect-error
8186 querystring [ key ] = params [ key ]
8287 }
8388 }
@@ -94,19 +99,31 @@ export default class Fleet {
9499 return await this . transport . request ( { path, method, querystring, bulkBody : body } , options )
95100 }
96101
97- async search ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptionsWithOutMeta ) : Promise < T . TODO >
98- async search ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptionsWithMeta ) : Promise < TransportResult < T . TODO , unknown > >
99- async search ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptions ) : Promise < T . TODO >
100- async search ( this : That , params ? : T . TODO | TB . TODO , options ?: TransportRequestOptions ) : Promise < any > {
102+ async search < TDocument = unknown > ( this : That , params : T . FleetSearchRequest | TB . FleetSearchRequest , options ?: TransportRequestOptionsWithOutMeta ) : Promise < T . FleetSearchResponse < TDocument > >
103+ async search < TDocument = unknown > ( this : That , params : T . FleetSearchRequest | TB . FleetSearchRequest , options ?: TransportRequestOptionsWithMeta ) : Promise < TransportResult < T . FleetSearchResponse < TDocument > , unknown > >
104+ async search < TDocument = unknown > ( this : That , params : T . FleetSearchRequest | TB . FleetSearchRequest , options ?: TransportRequestOptions ) : Promise < T . FleetSearchResponse < TDocument > >
105+ async search < TDocument = unknown > ( this : That , params : T . FleetSearchRequest | TB . FleetSearchRequest , options ?: TransportRequestOptions ) : Promise < any > {
101106 const acceptedPath : string [ ] = [ 'index' ]
107+ const acceptedBody : string [ ] = [ 'aggregations' , 'aggs' , 'collapse' , 'explain' , 'from' , 'highlight' , 'track_total_hits' , 'indices_boost' , 'docvalue_fields' , 'min_score' , 'post_filter' , 'profile' , 'query' , 'rescore' , 'script_fields' , 'search_after' , 'size' , 'slice' , 'sort' , '_source' , 'fields' , 'suggest' , 'terminate_after' , 'timeout' , 'track_scores' , 'version' , 'seq_no_primary_term' , 'stored_fields' , 'pit' , 'runtime_mappings' , 'stats' ]
102108 const querystring : Record < string , any > = { }
103- const body = undefined
109+ // @ts -expect-error
110+ const userBody : any = params ?. body
111+ let body : Record < string , any > | string
112+ if ( typeof userBody === 'string' ) {
113+ body = userBody
114+ } else {
115+ body = userBody != null ? { ...userBody } : undefined
116+ }
104117
105- params = params ?? { }
106118 for ( const key in params ) {
107- if ( acceptedPath . includes ( key ) ) {
119+ if ( acceptedBody . includes ( key ) ) {
120+ body = body ?? { }
121+ // @ts -expect-error
122+ body [ key ] = params [ key ]
123+ } else if ( acceptedPath . includes ( key ) ) {
108124 continue
109125 } else if ( key !== 'body' ) {
126+ // @ts -expect-error
110127 querystring [ key ] = params [ key ]
111128 }
112129 }
0 commit comments