From b37f25114897cb5dde78781f58badf890d8a7b48 Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Fri, 21 Feb 2020 12:43:18 +1000 Subject: [PATCH] Add categorization analyzer to defaults on ml info response Relates: #4341, elastic/elasticsearch#49545 --- .../MachineLearningInfoResponse.cs | 15 ++++++++++++++- .../MachineLearningInfoApiTests.cs | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Nest/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoResponse.cs b/src/Nest/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoResponse.cs index 82f6afc6999..ffa03299845 100644 --- a/src/Nest/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoResponse.cs +++ b/src/Nest/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoResponse.cs @@ -1,4 +1,5 @@ -using System.Runtime.Serialization; +using System.Collections.Generic; +using System.Runtime.Serialization; namespace Nest { @@ -33,6 +34,18 @@ public class AnomalyDetectors [DataMember(Name = "model_snapshot_retention_days")] public int ModelSnapshotRetentionDays { get; internal set; } + + [DataMember(Name = "categorization_analyzer")] + public CategorizationAnalyzer CategorizationAnalyzer { get; internal set; } + } + + public class CategorizationAnalyzer + { + [DataMember(Name = "tokenizer")] + public string Tokenizer { get; internal set; } + + [DataMember(Name = "filter")] + public IReadOnlyCollection Filter { get; internal set; } } public class Datafeeds diff --git a/tests/Tests/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoApiTests.cs b/tests/Tests/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoApiTests.cs index a9ec4ee45ce..2421ca34fcd 100644 --- a/tests/Tests/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoApiTests.cs +++ b/tests/Tests/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoApiTests.cs @@ -34,11 +34,20 @@ protected override void ExpectResponse(MachineLearningInfoResponse response) { response.ShouldBeValid(); - response.Defaults.AnomalyDetectors.ModelMemoryLimit.Should().Be("1gb"); - response.Defaults.AnomalyDetectors.CategorizationExamplesLimit.Should().Be(4); - response.Defaults.AnomalyDetectors.ModelSnapshotRetentionDays.Should().Be(1); + var anomalyDetectors = response.Defaults.AnomalyDetectors; + anomalyDetectors.ModelMemoryLimit.Should().Be("1gb"); + anomalyDetectors.CategorizationExamplesLimit.Should().Be(4); + anomalyDetectors.ModelSnapshotRetentionDays.Should().Be(1); response.Defaults.Datafeeds.ScrollSize.Should().Be(1000); + + if (Cluster.ClusterConfiguration.Version >= "7.6.0") + { + var analyzer = anomalyDetectors.CategorizationAnalyzer; + analyzer.Should().NotBeNull(); + analyzer.Tokenizer.Should().Be("ml_classic"); + analyzer.Filter.Should().NotBeNullOrEmpty(); + } } } }