Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/Nest/Aggregations/Bucket/Sampler/SamplerAggregation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ namespace Nest
[ReadAs(typeof(SamplerAggregation))]
public interface ISamplerAggregation : IBucketAggregation
{
[DataMember(Name ="execution_hint")]
SamplerAggregationExecutionHint? ExecutionHint { get; set; }

[DataMember(Name ="max_docs_per_value")]
int? MaxDocsPerValue { get; set; }

[DataMember(Name ="script")]
IScript Script { get; set; }

[DataMember(Name ="shard_size")]
int? ShardSize { get; set; }
}
Expand All @@ -31,9 +22,6 @@ internal SamplerAggregation() { }

public SamplerAggregation(string name) : base(name) { }

public SamplerAggregationExecutionHint? ExecutionHint { get; set; }
public int? MaxDocsPerValue { get; set; }
public IScript Script { get; set; }
public int? ShardSize { get; set; }

internal override void WrapInContainer(AggregationContainer c) => c.Sampler = this;
Expand All @@ -43,21 +31,8 @@ public class SamplerAggregationDescriptor<T>
: BucketAggregationDescriptorBase<SamplerAggregationDescriptor<T>, ISamplerAggregation, T>, ISamplerAggregation
where T : class
{
SamplerAggregationExecutionHint? ISamplerAggregation.ExecutionHint { get; set; }
int? ISamplerAggregation.MaxDocsPerValue { get; set; }
IScript ISamplerAggregation.Script { get; set; }
int? ISamplerAggregation.ShardSize { get; set; }

public SamplerAggregationDescriptor<T> ExecutionHint(SamplerAggregationExecutionHint? executionHint) =>
Assign(executionHint, (a, v) => a.ExecutionHint = v);

public SamplerAggregationDescriptor<T> MaxDocsPerValue(int? maxDocs) => Assign(maxDocs, (a, v) => a.MaxDocsPerValue = v);

public SamplerAggregationDescriptor<T> Script(string script) => Assign((InlineScript)script, (a, v) => a.Script = v);

public SamplerAggregationDescriptor<T> Script(Func<ScriptDescriptor, IScript> scriptSelector) =>
Assign(scriptSelector, (a, v) => a.Script = v?.Invoke(new ScriptDescriptor()));

public SamplerAggregationDescriptor<T> ShardSize(int? shardSize) => Assign(shardSize, (a, v) => a.ShardSize = v);
}
}

This file was deleted.

58 changes: 50 additions & 8 deletions tests/Examples/Aggregations/Bucket/SamplerAggregationPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,34 @@ namespace Examples.Aggregations.Bucket
{
public class SamplerAggregationPage : ExampleBase
{
[U(Skip = "Example not implemented")]
[U]
[Description("aggregations/bucket/sampler-aggregation.asciidoc:19")]
public void Line19()
{
// tag::28035a0e2a874f1b6739badf82a0ecc6[]
var response0 = new SearchResponse<object>();
var searchResponse = client.Search<object>(s => s
.Index("stackoverflow")
.Query(q => q
.QueryString(qs => qs
.Query("tags:kibana OR tags:javascript")
)
)
.Aggregations(a => a
.Sampler("sample", s => s
.ShardSize(200)
.Aggregations(sa => sa
.SignificantTerms("keywords", k => k
.Field("tags")
.Exclude(new string[] { "kibana", "javascript" })
)
)
)
)
.Size(0)
);
// end::28035a0e2a874f1b6739badf82a0ecc6[]

response0.MatchesExample(@"POST /stackoverflow/_search?size=0
searchResponse.MatchesExample(@"POST /stackoverflow/_search?size=0
{
""query"": {
""query_string"": {
Expand All @@ -40,18 +59,37 @@ public void Line19()
}
}
}
}");
}", (e, b) =>
{
e.Uri.Query = e.Uri.Query.Replace("size=0", string.Empty);
b["size"] = 0;
});
}

[U(Skip = "Example not implemented")]
[U]
[Description("aggregations/bucket/sampler-aggregation.asciidoc:88")]
public void Line88()
{
// tag::279f7af39b62c7d278f9f10b1f107dc0[]
var response0 = new SearchResponse<object>();
var searchResponse = client.Search<object>(s => s
.Index("stackoverflow")
.Query(q => q
.QueryString(qs => qs
.Query("tags:kibana OR tags:javascript")
)
)
.Aggregations(a => a
.SignificantTerms("low_quality_keywords", k => k
.Field("tags")
.Size(3)
.Exclude(new string[] { "kibana", "javascript" })
)
)
.Size(0)
);
// end::279f7af39b62c7d278f9f10b1f107dc0[]

response0.MatchesExample(@"POST /stackoverflow/_search?size=0
searchResponse.MatchesExample(@"POST /stackoverflow/_search?size=0
{
""query"": {
""query_string"": {
Expand All @@ -67,7 +105,11 @@ public void Line88()
}
}
}
}");
}", (e, b) =>
{
e.Uri.Query = e.Uri.Query.Replace("size=0", string.Empty);
b["size"] = 0;
});
}
}
}