Skip to content

Commit

Permalink
Add annotations_enabled to model config (#4919)
Browse files Browse the repository at this point in the history
  • Loading branch information
russcam authored Aug 5, 2020
1 parent 3f08a45 commit 5ee62fb
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/Nest/XPack/MachineLearning/Job/Config/ModelPlotConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ public interface IModelPlotConfig : IModelPlotConfigEnabled
/// </remarks>
[DataMember(Name ="terms")]
Fields Terms { get; set; }

/// <summary>
/// If <c>true</c>, enables calculation and storage of the model change annotations
/// for each entity that is being analyzed. By default, this is not enabled.
/// <para />
/// Valid in Elasticsearch 7.9.0+
/// </summary>
[DataMember(Name = "annotations_enabled")]
bool? AnnotationsEnabled { get; set; }
}

/// <inheritdoc />
Expand All @@ -33,23 +42,31 @@ public class ModelPlotConfig : IModelPlotConfig

/// <inheritdoc />
public Fields Terms { get; set; }

/// <inheritdoc />
public bool? AnnotationsEnabled { get; set; }
}

/// <inheritdoc />
public class ModelPlotConfigDescriptor<T> : DescriptorBase<ModelPlotConfigDescriptor<T>, IModelPlotConfig>, IModelPlotConfig where T : class
{
bool? IModelPlotConfigEnabled.Enabled { get; set; }
Fields IModelPlotConfig.Terms { get; set; }
bool? IModelPlotConfig.AnnotationsEnabled { get; set; }

/// <inheritdoc />
/// <inheritdoc cref="IModelPlotConfigEnabled.Enabled" />
public ModelPlotConfigDescriptor<T> Enabled(bool? enabled = true) => Assign(enabled, (a, v) => a.Enabled = v);

/// <inheritdoc />
/// <inheritdoc cref="IModelPlotConfig.Terms" />
public ModelPlotConfigDescriptor<T> Terms(Func<FieldsDescriptor<T>, IPromise<Fields>> fields) =>
Assign(fields, (a, v) => a.Terms = v?.Invoke(new FieldsDescriptor<T>())?.Value);

/// <inheritdoc />
/// <inheritdoc cref="IModelPlotConfig.Terms" />
public ModelPlotConfigDescriptor<T> Terms(Fields fields) => Assign(fields, (a, v) => a.Terms = v);

/// <inheritdoc cref="IModelPlotConfig.AnnotationsEnabled" />
public ModelPlotConfigDescriptor<T> AnnotationsEnabled(bool? enabled = true) =>
Assign(enabled, (a, v) => a.AnnotationsEnabled = v);
}

/// <summary>
Expand Down

0 comments on commit 5ee62fb

Please sign in to comment.