Skip to content

Commit 40889d1

Browse files
authored
Add categorization analyzer to defaults on ml info response (#4408)
Relates: #4341, elastic/elasticsearch#49545
1 parent 31ecd9c commit 40889d1

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/Nest/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoResponse.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.Serialization;
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
23

34
namespace Nest
45
{
@@ -33,6 +34,18 @@ public class AnomalyDetectors
3334

3435
[DataMember(Name = "model_snapshot_retention_days")]
3536
public int ModelSnapshotRetentionDays { get; internal set; }
37+
38+
[DataMember(Name = "categorization_analyzer")]
39+
public CategorizationAnalyzer CategorizationAnalyzer { get; internal set; }
40+
}
41+
42+
public class CategorizationAnalyzer
43+
{
44+
[DataMember(Name = "tokenizer")]
45+
public string Tokenizer { get; internal set; }
46+
47+
[DataMember(Name = "filter")]
48+
public IReadOnlyCollection<ITokenFilter> Filter { get; internal set; }
3649
}
3750

3851
public class Datafeeds

tests/Tests/XPack/MachineLearning/MachineLearningInfo/MachineLearningInfoApiTests.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,20 @@ protected override void ExpectResponse(MachineLearningInfoResponse response)
3434
{
3535
response.ShouldBeValid();
3636

37-
response.Defaults.AnomalyDetectors.ModelMemoryLimit.Should().Be("1gb");
38-
response.Defaults.AnomalyDetectors.CategorizationExamplesLimit.Should().Be(4);
39-
response.Defaults.AnomalyDetectors.ModelSnapshotRetentionDays.Should().Be(1);
37+
var anomalyDetectors = response.Defaults.AnomalyDetectors;
38+
anomalyDetectors.ModelMemoryLimit.Should().Be("1gb");
39+
anomalyDetectors.CategorizationExamplesLimit.Should().Be(4);
40+
anomalyDetectors.ModelSnapshotRetentionDays.Should().Be(1);
4041

4142
response.Defaults.Datafeeds.ScrollSize.Should().Be(1000);
43+
44+
if (Cluster.ClusterConfiguration.Version >= "7.6.0")
45+
{
46+
var analyzer = anomalyDetectors.CategorizationAnalyzer;
47+
analyzer.Should().NotBeNull();
48+
analyzer.Tokenizer.Should().Be("ml_classic");
49+
analyzer.Filter.Should().NotBeNullOrEmpty();
50+
}
4251
}
4352
}
4453
}

0 commit comments

Comments
 (0)