11using System ;
22using System . Collections . Generic ;
3+ using System . IO ;
34using System . Linq ;
45using System . Threading . Tasks ;
56using Elasticsearch . Net ;
89
910namespace Nest
1011{
12+ using MultiGetConverter = Func < IElasticsearchResponse , Stream , MultiGetResponse > ;
13+
1114 public partial class ElasticClient
1215 {
1316 /// <inheritdoc />
@@ -16,9 +19,10 @@ public IMultiGetResponse MultiGet(Func<MultiGetDescriptor, MultiGetDescriptor> m
1619 multiGetSelector . ThrowIfNull ( "multiGetSelector" ) ;
1720 var descriptor = multiGetSelector ( new MultiGetDescriptor ( _connectionSettings ) ) ;
1821 var converter = CreateCovariantMultiGetConverter ( descriptor ) ;
22+ var customCreator = new MultiGetConverter ( ( r , s ) => this . DeserializeMultiGetResponse ( r , s , converter ) ) ;
1923 return this . Dispatch < MultiGetDescriptor , MultiGetRequestParameters , MultiGetResponse > (
2024 descriptor ,
21- ( p , d ) => this . RawDispatch . MgetDispatch < MultiGetResponse > ( p . DeserializationState ( converter ) , d )
25+ ( p , d ) => this . RawDispatch . MgetDispatch < MultiGetResponse > ( p . DeserializationState ( customCreator ) , d )
2226 ) ;
2327 }
2428
@@ -28,12 +32,16 @@ public Task<IMultiGetResponse> MultiGetAsync(Func<MultiGetDescriptor, MultiGetDe
2832 multiGetSelector . ThrowIfNull ( "multiGetSelector" ) ;
2933 var descriptor = multiGetSelector ( new MultiGetDescriptor ( _connectionSettings ) ) ;
3034 var converter = CreateCovariantMultiGetConverter ( descriptor ) ;
35+ var customCreator = new MultiGetConverter ( ( r , s ) => this . DeserializeMultiGetResponse ( r , s , converter ) ) ;
3136 return this . DispatchAsync < MultiGetDescriptor , MultiGetRequestParameters , MultiGetResponse , IMultiGetResponse > (
3237 descriptor ,
33- ( p , d ) => this . RawDispatch . MgetDispatchAsync < MultiGetResponse > ( p . DeserializationState ( converter ) , d )
38+ ( p , d ) => this . RawDispatch . MgetDispatchAsync < MultiGetResponse > ( p . DeserializationState ( customCreator ) , d )
3439 ) ;
3540 }
36-
41+ private MultiGetResponse DeserializeMultiGetResponse ( IElasticsearchResponse response , Stream stream , JsonConverter converter )
42+ {
43+ return this . Serializer . DeserializeInternal < MultiGetResponse > ( stream , converter ) ;
44+ }
3745 private JsonConverter CreateCovariantMultiGetConverter ( MultiGetDescriptor descriptor )
3846 {
3947 var multiGetHitConverter = new MultiGetHitConverter ( descriptor ) ;
0 commit comments