Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 7.x] Add annotations_enabled to model config #4942

Merged
merged 1 commit into from
Aug 5, 2020
Merged
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
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