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
24 changes: 24 additions & 0 deletions src/Nest/DSL/Aggregations/SignificantTermsAggregationDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public interface ISignificantTermsAggregator : IBucketAggregator
[JsonProperty("gnd")]
GoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; }

[JsonProperty("percentage")]
PercentageScoreHeuristic PercentageScore { get; set; }

[JsonProperty("script_heuristic")]
ScriptedHeuristic Script { get; set; }

[JsonProperty("background_filter")]
IFilterContainer BackgroundFilter { get; set; }

Expand All @@ -57,6 +63,8 @@ public class SignificantTermsAggregator : BucketAggregator, ISignificantTermsAgg
public MutualInformationHeuristic MutualInformation { get; set; }
public ChiSquareHeuristic ChiSquare { get; set; }
public GoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; }
public PercentageScoreHeuristic PercentageScore { get; set; }
public ScriptedHeuristic Script { get; set; }
public IFilterContainer BackgroundFilter { get; set; }
}

Expand Down Expand Up @@ -84,6 +92,10 @@ public class SignificantTermsAggregationDescriptor<T> : BucketAggregationBaseDes

GoogleNormalizedDistanceHeuristic ISignificantTermsAggregator.GoogleNormalizedDistance { get; set; }

PercentageScoreHeuristic ISignificantTermsAggregator.PercentageScore { get; set; }

ScriptedHeuristic ISignificantTermsAggregator.Script { get; set; }

IFilterContainer ISignificantTermsAggregator.BackgroundFilter { get; set; }

public SignificantTermsAggregationDescriptor<T> Field(string field)
Expand Down Expand Up @@ -167,6 +179,18 @@ public SignificantTermsAggregationDescriptor<T> GoogleNormalizedDistance(bool? b
return this;
}

public SignificantTermsAggregationDescriptor<T> PercentageScore()
{
this.Self.PercentageScore = new PercentageScoreHeuristic();
return this;
}

public SignificantTermsAggregationDescriptor<T> Script(Func<ScriptedHeuristicDescriptor, ScriptedHeuristicDescriptor> scriptSelector)
{
this.Self.Script = scriptSelector(new ScriptedHeuristicDescriptor()).ScriptedHeuristic;
return this;
}

public SignificantTermsAggregationDescriptor<T> BackgroundFilter(Func<FilterDescriptor<T>, FilterContainer> selector)
{
this.Self.BackgroundFilter = selector(new FilterDescriptor<T>());
Expand Down
36 changes: 36 additions & 0 deletions src/Nest/Domain/Aggregations/ISignificantTermsHeuristic.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using System;

namespace Nest
{
Expand All @@ -25,4 +26,39 @@ public class GoogleNormalizedDistanceHeuristic
public bool? BackgroundIsSuperSet { get; set; }
}

public class PercentageScoreHeuristic
{
}

public class ScriptedHeuristic
{
[JsonProperty("script")]
public string Script { get; set; }
[JsonProperty("lang")]
public string Lang { get; set; }
[JsonProperty("params")]
public IDictionary<string, object> Params { get; set; }
}

public class ScriptedHeuristicDescriptor
{
internal ScriptedHeuristic ScriptedHeuristic = new ScriptedHeuristic();
public ScriptedHeuristicDescriptor Script(string script)
{
this.ScriptedHeuristic.Script = script;
return this;
}

public ScriptedHeuristicDescriptor Lang(string lang)
{
this.ScriptedHeuristic.Lang = lang;
return this;
}

public ScriptedHeuristicDescriptor Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> paramsSelector)
{
this.ScriptedHeuristic.Params = paramsSelector(new FluentDictionary<string, object>());
return this;
}
}
}