Skip to content

Commit 50b1194

Browse files
committed
Merge pull request #1385 from elastic/feature/cat-segments
Add support for cat segments
2 parents 1808005 + 0175583 commit 50b1194

File tree

9 files changed

+356
-556
lines changed

9 files changed

+356
-556
lines changed

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/root.html

Lines changed: 232 additions & 542 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Elasticsearch.Net;
2+
using Newtonsoft.Json;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
8+
namespace Nest
9+
{
10+
11+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
12+
public interface ICatSegmentsRequest : IRequest<CatSegmentsRequestParameters>
13+
{
14+
}
15+
16+
public partial class CatSegmentsRequest : BasePathRequest<CatSegmentsRequestParameters>, ICatSegmentsRequest
17+
{
18+
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<CatSegmentsRequestParameters> pathInfo)
19+
{
20+
CatRequestPathInfo.Update(pathInfo);
21+
}
22+
}
23+
24+
public partial class CatSegmentsDescriptor : BasePathDescriptor<CatSegmentsDescriptor, CatSegmentsRequestParameters>, ICatSegmentsRequest
25+
{
26+
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<CatSegmentsRequestParameters> pathInfo)
27+
{
28+
CatRequestPathInfo.Update(pathInfo);
29+
}
30+
}
31+
}

src/Nest/DSL/_Descriptors.generated.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ public CatRecoveryDescriptor V(bool v = true)
766766
///http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-segments.html
767767
///</pre>
768768
///</summary>
769-
public partial class CatSegmentsDescriptor : BaseRequest<CatSegmentsRequestParameters>
769+
public partial class CatSegmentsDescriptor
770770
{
771771

772772

@@ -794,12 +794,6 @@ public CatSegmentsDescriptor V(bool v = true)
794794
return this;
795795
}
796796

797-
798-
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<CatSegmentsRequestParameters> pathInfo)
799-
{
800-
throw new NotImplementedException();
801-
}
802-
803797

804798
}
805799

src/Nest/DSL/_Requests.generated.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ public bool V
715715
///http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-segments.html
716716
///</pre>
717717
///</summary>
718-
public partial class CatSegmentsRequest : BasePathRequest<CatSegmentsRequestParameters>
718+
public partial class CatSegmentsRequest
719719
{
720720

721721
///<summary>Comma-separated list of column names to display</summary>
@@ -741,12 +741,6 @@ public bool V
741741
set { this.Request.RequestParameters.AddQueryString("v", value); }
742742
}
743743

744-
745-
protected override void UpdatePathInfo(IConnectionSettingsValues settings, ElasticsearchPathInfo<CatSegmentsRequestParameters> pathInfo)
746-
{
747-
throw new NotImplementedException();
748-
}
749-
750744
}
751745

752746

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace Nest
8+
{
9+
[JsonObject]
10+
public class CatSegmentsRecord : ICatRecord
11+
{
12+
[JsonProperty("index")]
13+
public string Index { get; set; }
14+
15+
[JsonProperty("shard")]
16+
public string Shard { get; set; }
17+
18+
[JsonProperty("prirep")]
19+
public string PrimaryReplica { get; set; }
20+
21+
[JsonProperty("ip")]
22+
public string Ip { get; set; }
23+
24+
[JsonProperty("segment")]
25+
public string Segment { get; set; }
26+
27+
[JsonProperty("generation")]
28+
public string Generation { get; set; }
29+
30+
[JsonProperty("docs.count")]
31+
public string DocsCount { get; set; }
32+
33+
[JsonProperty("docs.deleted")]
34+
public string DocsDeleted { get; set; }
35+
36+
[JsonProperty("size")]
37+
public string Size { get; set; }
38+
39+
[JsonProperty("size.memory")]
40+
public string SizeMemory { get; set; }
41+
42+
[JsonProperty("committed")]
43+
public string Committed { get; set; }
44+
45+
[JsonProperty("searchable")]
46+
public string Searchable { get; set; }
47+
48+
[JsonProperty("version")]
49+
public string Version { get; set; }
50+
51+
[JsonProperty("compound")]
52+
public string Compound { get; set; }
53+
}
54+
}

src/Nest/ElasticClient-Cat.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,25 @@ public Task<ICatResponse<CatFielddataRecord>> CatFielddataAsync(ICatFielddataReq
283283
return this.DoCatAsync<ICatFielddataRequest, CatFielddataRequestParameters, CatFielddataRecord>(request, this.RawDispatch.CatFielddataDispatchAsync<CatResponse<CatFielddataRecord>>);
284284
}
285285

286+
public ICatResponse<CatSegmentsRecord> CatSegments(Func<CatSegmentsDescriptor, CatSegmentsDescriptor> selector = null)
287+
{
288+
return this.DoCat<CatSegmentsDescriptor, CatSegmentsRequestParameters, CatSegmentsRecord>(selector, this.RawDispatch.CatSegmentsDispatch<CatResponse<CatSegmentsRecord>>);
289+
}
290+
291+
public ICatResponse<CatSegmentsRecord> CatSegments(ICatSegmentsRequest request)
292+
{
293+
return this.DoCat<ICatSegmentsRequest, CatSegmentsRequestParameters, CatSegmentsRecord>(request, this.RawDispatch.CatSegmentsDispatch<CatResponse<CatSegmentsRecord>>);
294+
}
286295

296+
public Task<ICatResponse<CatSegmentsRecord>> CatSegmentsAsync(Func<CatSegmentsDescriptor, CatSegmentsDescriptor> selector = null)
297+
{
298+
return this.DoCatAsync<CatSegmentsDescriptor, CatSegmentsRequestParameters, CatSegmentsRecord>(selector, this.RawDispatch.CatSegmentsDispatchAsync<CatResponse<CatSegmentsRecord>>);
299+
}
300+
301+
public Task<ICatResponse<CatSegmentsRecord>> CatSegmentsAsync(ICatSegmentsRequest request)
302+
{
303+
return this.DoCatAsync<ICatSegmentsRequest, CatSegmentsRequestParameters, CatSegmentsRecord>(request, this.RawDispatch.CatSegmentsDispatchAsync<CatResponse<CatSegmentsRecord>>);
304+
}
287305

288306
private CatResponse<TCatRecord> DeserializeCatResponse<TCatRecord>(IElasticsearchResponse response, Stream stream)
289307
where TCatRecord : ICatRecord

src/Nest/IElasticClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,5 +1761,11 @@ Task<IExistsResponse> SearchExistsAsync<T>(Func<SearchExistsDescriptor<T>, Searc
17611761
ICatResponse<CatFielddataRecord> CatFielddata(ICatFielddataRequest request);
17621762
Task<ICatResponse<CatFielddataRecord>> CatFielddataAsync(Func<CatFielddataDescriptor, CatFielddataDescriptor> selector = null);
17631763
Task<ICatResponse<CatFielddataRecord>> CatFielddataAsync(ICatFielddataRequest request);
1764+
1765+
/// <inheritdoc />
1766+
ICatResponse<CatSegmentsRecord> CatSegments(Func<CatSegmentsDescriptor, CatSegmentsDescriptor> selector = null);
1767+
ICatResponse<CatSegmentsRecord> CatSegments(ICatSegmentsRequest request);
1768+
Task<ICatResponse<CatSegmentsRecord>> CatSegmentsAsync(Func<CatSegmentsDescriptor, CatSegmentsDescriptor> selector = null);
1769+
Task<ICatResponse<CatSegmentsRecord>> CatSegmentsAsync(ICatSegmentsRequest request);
17641770
}
17651771
}

src/Nest/Nest.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<Compile Include="Domain\Analysis\TokenFilter\StemmerOverrideTokenFilter.cs" />
120120
<Compile Include="Domain\Analysis\TokenFilter\UppercaseTokenFilter.cs" />
121121
<Compile Include="Domain\Bulk\IBulkOperation.cs" />
122+
<Compile Include="Domain\Cat\CatSegmentsRecord.cs" />
122123
<Compile Include="Domain\Cluster\ClusterRerouteDecision.cs" />
123124
<Compile Include="Domain\Cluster\ClusterRerouteExplanation.cs" />
124125
<Compile Include="Domain\Cluster\ClusterRerouteParameters.cs" />
@@ -217,6 +218,7 @@
217218
<Compile Include="Domain\Stats\PercolateStats.cs" />
218219
<Compile Include="Domain\Stats\PluginStats.cs" />
219220
<Compile Include="Domain\Stats\SegmentsStats.cs" />
221+
<Compile Include="DSL\CatSegmentsDescriptor.cs" />
220222
<Compile Include="DSL\ClusterRerouteDescriptor.cs" />
221223
<Compile Include="DSL\Cluster\AllocateClusterRerouteCommand.cs" />
222224
<Compile Include="DSL\Cluster\AllocateClusterRerouteCommandDescriptor.cs" />

src/Tests/Nest.Tests.Integration/Core/Cat/CatTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,16 @@ public async void CatShardsAsync()
211211
await TestCatAsync(() => this._client.CatShardsAsync(), r => !r.State.IsNullOrEmpty());
212212
}
213213

214+
[Test]
215+
public void CatSegments()
216+
{
217+
TestCat(() => this._client.CatSegments(), r => !r.Index.IsNullOrEmpty() && !r.Shard.IsNullOrEmpty() && !r.PrimaryReplica.IsNullOrEmpty() && !r.Ip.IsNullOrEmpty() && !r.Segment.IsNullOrEmpty() && !r.Generation.IsNullOrEmpty() && !r.DocsCount.IsNullOrEmpty() && !r.DocsDeleted.IsNullOrEmpty() && !r.Size.IsNullOrEmpty() && !r.SizeMemory.IsNullOrEmpty() && !r.Committed.IsNullOrEmpty() && !r.Searchable.IsNullOrEmpty() && !r.Version.IsNullOrEmpty() && !r.Compound.IsNullOrEmpty());
218+
}
219+
220+
[Test]
221+
public async void CatSegmentsAsync()
222+
{
223+
await TestCatAsync(() => this._client.CatSegmentsAsync(), r => !r.Index.IsNullOrEmpty() && !r.Shard.IsNullOrEmpty() && !r.PrimaryReplica.IsNullOrEmpty() && !r.Ip.IsNullOrEmpty() && !r.Segment.IsNullOrEmpty() && !r.Generation.IsNullOrEmpty() && !r.DocsCount.IsNullOrEmpty() && !r.DocsDeleted.IsNullOrEmpty() && !r.Size.IsNullOrEmpty() && !r.SizeMemory.IsNullOrEmpty() && !r.Committed.IsNullOrEmpty() && !r.Searchable.IsNullOrEmpty() && !r.Version.IsNullOrEmpty() && !r.Compound.IsNullOrEmpty());
224+
}
214225
}
215226
}

0 commit comments

Comments
 (0)