File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
CommonAbstractions/Infer/Id
Tests/Document/Single/Index Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ internal string GetString(IConnectionSettingsValues nestSettings)
3030 {
3131 if ( this . Document != null )
3232 {
33- return nestSettings . Inferrer . Id ( this . Document ) ;
33+ Value = nestSettings . Inferrer . Id ( this . Document ) ;
3434 }
3535
3636 var s = Value as string ;
Original file line number Diff line number Diff line change @@ -17,18 +17,20 @@ public partial interface IIndexRequest<TDocument> : IIndexRequest where TDocumen
1717 public partial class IndexRequest < TDocument >
1818 where TDocument : class
1919 {
20- protected override HttpMethod HttpMethod => ( ( IIndexRequest < TDocument > ) this ) . Id == null ? HttpMethod . POST : HttpMethod . PUT ;
20+ protected override HttpMethod HttpMethod => GetHttpMethod ( this ) ;
2121
2222 partial void DocumentFromPath ( TDocument doc ) => this . Document = doc ;
2323
2424 object IIndexRequest . UntypedDocument => this . Document ;
2525
2626 public TDocument Document { get ; set ; }
27+
28+ internal static HttpMethod GetHttpMethod ( IIndexRequest < TDocument > r ) => ( r . Id != null && r . Id . Value != null ) ? HttpMethod . PUT : HttpMethod . POST ;
2729 }
2830
2931 public partial class IndexDescriptor < TDocument > where TDocument : class
3032 {
31- protected override HttpMethod HttpMethod => Self . Id == null ? HttpMethod . POST : HttpMethod . PUT ;
33+ protected override HttpMethod HttpMethod => IndexRequest < TDocument > . GetHttpMethod ( this ) ;
3234 partial void DocumentFromPath ( TDocument doc ) => Assign ( a => a . Document = doc ) ;
3335 object IIndexRequest . UntypedDocument => Self . Document ;
3436
Original file line number Diff line number Diff line change @@ -22,6 +22,16 @@ await POST("/project/project")
2222 } ) )
2323 ;
2424
25+ await POST ( "/project/project" )
26+ . Fluent ( c => c . Index ( new { } , i => i . Index ( typeof ( Project ) ) . Type ( typeof ( Project ) ) ) )
27+ . Request ( c => c . Index ( new IndexRequest < object > ( "project" , "project" ) { Document = new { } } ) )
28+ . FluentAsync ( c => c . IndexAsync ( new { } , i => i . Index ( typeof ( Project ) ) . Type ( typeof ( Project ) ) ) )
29+ . RequestAsync ( c => c . IndexAsync ( new IndexRequest < object > ( typeof ( Project ) , TypeName . From < Project > ( ) )
30+ {
31+ Document = new { }
32+ } ) )
33+ ;
34+
2535 await PUT ( "/project/project/NEST" )
2636 . Fluent ( c => c . Index ( project ) )
2737 . Request ( c => c . Index ( new IndexRequest < Project > ( "project" , "project" , "NEST" ) { Document = project } ) )
You can’t perform that action at this time.
0 commit comments