Skip to content

Commit ea98c70

Browse files
committed
Added Delete<T>(T obj) extension on IElasticClient
1 parent 10d4b02 commit ea98c70

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

build.bat

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ if not exist build\tools\node_modules\wintersmith\bin\wintersmith (
3939

4040

4141
SET TARGET="Build"
42+
SET VERSION="0.1.0"
4243

4344
IF NOT [%1]==[] (set TARGET="%1")
4445

45-
"build\tools\FAKE\tools\Fake.exe" "build\build.fsx" "target=%TARGET%"
46+
IF NOT [%2]==[] (set VERSION="%2")
47+
48+
shift
49+
shift
50+
51+
"build\tools\FAKE\tools\Fake.exe" "build\build.fsx" "target=%TARGET%" "version=%VERSION%"

build/build.fsx

+12-5
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,22 @@ let buildDocs = fun action ->
8989
p.Arguments <- sprintf "\"%s\" %s" wintersmith action
9090
) (TimeSpan.FromMinutes (if action = "preview" then 300.0 else 5.0))
9191

92+
Target "Version" (fun _ ->
93+
let v = (getBuildParamOrDefault "version" "0.1.0")
94+
let version = SemVerHelper.parse v
95+
let assemblyVersion = sprintf "%i.%i.0.0" version.Major version.Minor
96+
97+
trace (sprintf "%s %s" v assemblyVersion)
98+
99+
)
92100

93101
Target "Release" (fun _ ->
94102
if not <| fileExists keyFile
95103
then failwithf "{0} does not exist to sign the assemblies" keyFile
96104

97-
signAssembly("Elasticsearch.Net")
98-
signAssembly("Elasticsearch.Net.Connection.Thrift")
99-
signAssembly("Nest")
105+
//signAssembly("Elasticsearch.Net")
106+
//signAssembly("Elasticsearch.Net.Connection.Thrift")
107+
//signAssembly("Nest")
100108

101109
nugetPack("Elasticsearch.Net")
102110
nugetPack("Elasticsearch.Net.Connection.Thrift")
@@ -110,7 +118,6 @@ Target "DocsPreview" (fun _ ->
110118
buildDocs "preview" |> ignore
111119
)
112120

113-
114121
// Dependencies
115122
"Clean"
116123
==> "BuildApp"
@@ -121,6 +128,6 @@ Target "DocsPreview" (fun _ ->
121128
==> "Release"
122129

123130
"DocsPreview"
124-
131+
"Version"
125132
// start build
126133
RunTargetOrDefault "Build"

src/Nest/ConvenienceExtensions/DeleteExtensions.cs

+32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Threading.Tasks;
3+
using Elasticsearch.Net;
34

45
namespace 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
}

src/Nest/Nest.csproj

+7
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666
<ErrorReport>prompt</ErrorReport>
6767
<CodeAnalysisRuleSet>BasicCorrectnessRules.ruleset</CodeAnalysisRuleSet>
6868
</PropertyGroup>
69+
<PropertyGroup>
70+
<SignAssembly>false</SignAssembly>
71+
</PropertyGroup>
72+
<PropertyGroup>
73+
<AssemblyOriginatorKeyFile>
74+
</AssemblyOriginatorKeyFile>
75+
</PropertyGroup>
6976
<ItemGroup>
7077
<Reference Include="Microsoft.CSharp" />
7178
<Reference Include="Newtonsoft.Json">

0 commit comments

Comments
 (0)