11using System ;
22using System . Threading . Tasks ;
3+ using Elasticsearch . Net ;
34
45namespace Nest
56{
@@ -63,5 +64,36 @@ public static Task<IDeleteResponse> DeleteAsync<T>(this IElasticClient client, s
6364 selector = selector ?? ( s => s ) ;
6465 return client . DeleteAsync < T > ( s => selector ( s . Id ( id ) ) ) ;
6566 }
67+ /// <summary>
68+ ///The delete API allows to delete a typed JSON document from a specific index based on its id.
69+ /// <para> </para>>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete.html
70+ /// </summary>
71+ /// <typeparam name="T">The type used to infer the default index and typename</typeparam>
72+ /// <param name="client"></param>
73+ /// <param name="obj">The object used to infer the id</param>
74+ /// <param name="selector">An optional descriptor to further describe the delete operation</param>
75+ public static IDeleteResponse Delete < T > ( this IElasticClient client , T obj , Func < DeleteDescriptor < T > , DeleteDescriptor < T > > selector = null ) where T : class
76+ {
77+ obj . ThrowIfNull ( "obj" ) ;
78+ var id = client . Infer . Id ( obj ) ;
79+ selector = selector ?? ( s => s ) ;
80+ return client . Delete < T > ( s => selector ( s . Id ( id ) ) ) ;
81+ }
82+
83+ /// <summary>
84+ ///The delete API allows to delete a typed JSON document from a specific index based on its id.
85+ /// <para> </para>>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete.html
86+ /// </summary>
87+ /// <typeparam name="T">The type used to infer the default index and typename</typeparam>
88+ /// <param name="client"></param>
89+ /// <param name="obj">The object used to infer the id</param>
90+ /// <param name="selector">An optional descriptor to further describe the delete operation</param>
91+ public static Task < IDeleteResponse > DeleteAsync < T > ( this IElasticClient client , T obj , Func < DeleteDescriptor < T > , DeleteDescriptor < T > > selector = null ) where T : class
92+ {
93+ obj . ThrowIfNull ( "obj" ) ;
94+ var id = client . Infer . Id ( obj ) ;
95+ selector = selector ?? ( s => s ) ;
96+ return client . DeleteAsync < T > ( s => selector ( s . Id ( id ) ) ) ;
97+ }
6698 }
6799}
0 commit comments