Skip to content

Commit c9329a2

Browse files
codebrainMpdreamz
authored andcommitted
Add option to stop machine learning datafeed that finds no data. (#4286)
Implements: elastic/elasticsearch#47922
1 parent fb1592b commit c9329a2

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

src/Nest/XPack/MachineLearning/Datafeed/DatafeedConfig.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,13 @@ public class DatafeedConfig
7575
[DataMember(Name = "scroll_size")]
7676
public int? ScrollSize { get; internal set; }
7777

78+
/// <summary>
79+
/// If a real-time datafeed has never seen any data (including during any initial training period) then it will automatically stop
80+
/// itself and close its associated job after this many real-time searches that return no documents. In other words, it will
81+
/// stop after <see cref="Frequency"/> times <see cref="MaximumEmptySearches"/> of real-time operation. If not set then a datafeed
82+
/// with no end time that sees no data will remain started until it is explicitly stopped.
83+
/// </summary>
84+
[DataMember(Name ="max_empty_searches")]
85+
public int? MaximumEmptySearches { get; set; }
7886
}
7987
}

src/Nest/XPack/MachineLearning/PutDatafeed/PutDatafeedRequest.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ public partial interface IPutDatafeedRequest
6969
/// </summary>
7070
[DataMember(Name ="scroll_size")]
7171
int? ScrollSize { get; set; }
72+
73+
/// <summary>
74+
/// If a real-time datafeed has never seen any data (including during any initial training period) then it will automatically stop
75+
/// itself and close its associated job after this many real-time searches that return no documents. In other words, it will
76+
/// stop after <see cref="Frequency"/> times <see cref="MaximumEmptySearches"/> of real-time operation. If not set then a datafeed
77+
/// with no end time that sees no data will remain started until it is explicitly stopped.
78+
/// <para/>
79+
/// By default this setting is not set.
80+
/// </summary>
81+
[DataMember(Name ="max_empty_searches")]
82+
int? MaximumEmptySearches { get; set; }
7283
}
7384

7485
/// <inheritdoc />
@@ -101,6 +112,8 @@ public partial class PutDatafeedRequest
101112
/// <inheritdoc />
102113
public int? ScrollSize { get; set; }
103114

115+
/// <inheritdoc />
116+
public int? MaximumEmptySearches { get; set; }
104117
}
105118

106119
public partial class PutDatafeedDescriptor<TDocument> where TDocument : class
@@ -114,6 +127,7 @@ public partial class PutDatafeedDescriptor<TDocument> where TDocument : class
114127
Time IPutDatafeedRequest.QueryDelay { get; set; }
115128
IScriptFields IPutDatafeedRequest.ScriptFields { get; set; }
116129
int? IPutDatafeedRequest.ScrollSize { get; set; }
130+
int? IPutDatafeedRequest.MaximumEmptySearches { get; set; }
117131

118132
/// <inheritdoc />
119133
public PutDatafeedDescriptor<TDocument> Aggregations(Func<AggregationContainerDescriptor<TDocument>, IAggregationContainer> aggregationsSelector) =>
@@ -152,5 +166,8 @@ public PutDatafeedDescriptor<TDocument> ScriptFields(Func<ScriptFieldsDescriptor
152166
/// <inheritdoc />
153167
public PutDatafeedDescriptor<TDocument> ScrollSize(int? scrollSize) => Assign(scrollSize, (a, v) => a.ScrollSize = v);
154168

169+
/// <inheritdoc />
170+
public PutDatafeedDescriptor<TDocument> MaximumEmptySearches(int? maximumEmptySearches) =>
171+
Assign(maximumEmptySearches, (a, v) => a.MaximumEmptySearches = v);
155172
}
156173
}

src/Nest/XPack/MachineLearning/PutDatafeed/PutDatafeedResponse.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,13 @@ public class PutDatafeedResponse : ResponseBase
6464
[DataMember(Name = "scroll_size")]
6565
public int? ScrollSize { get; internal set; }
6666

67+
/// <summary>
68+
/// If a real-time datafeed has never seen any data (including during any initial training period) then it will automatically stop
69+
/// itself and close its associated job after this many real-time searches that return no documents. In other words, it will
70+
/// stop after <see cref="Frequency"/> times <see cref="MaximumEmptySearches"/> of real-time operation. If not set then a datafeed
71+
/// with no end time that sees no data will remain started until it is explicitly stopped.
72+
/// </summary>
73+
[DataMember(Name ="max_empty_searches")]
74+
public int? MaximumEmptySearches { get; set; }
6775
}
6876
}

src/Nest/XPack/MachineLearning/UpdateDataFeed/UpdateDatafeedRequest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ public partial interface IUpdateDatafeedRequest
6868
/// </summary>
6969
[DataMember(Name ="scroll_size")]
7070
int? ScrollSize { get; set; }
71+
72+
/// <summary>
73+
/// If a real-time datafeed has never seen any data (including during any initial training period) then it will automatically stop
74+
/// itself and close its associated job after this many real-time searches that return no documents. In other words, it will
75+
/// stop after <see cref="Frequency"/> times <see cref="MaximumEmptySearches"/> of real-time operation. If not set then a datafeed
76+
/// with no end time that sees no data will remain started until it is explicitly stopped.
77+
/// <para/>
78+
/// The special value `-1` unsets this setting.
79+
/// </summary>
80+
[DataMember(Name ="max_empty_searches")]
81+
int? MaximumEmptySearches { get; set; }
7182
}
7283

7384
/// <inheritdoc />
@@ -100,6 +111,9 @@ public partial class UpdateDatafeedRequest
100111

101112
/// <inheritdoc />
102113
public int? ScrollSize { get; set; }
114+
115+
/// <inheritdoc />
116+
public int? MaximumEmptySearches { get; set; }
103117
}
104118

105119
public partial class UpdateDatafeedDescriptor<TDocument> where TDocument : class
@@ -113,6 +127,7 @@ public partial class UpdateDatafeedDescriptor<TDocument> where TDocument : class
113127
Time IUpdateDatafeedRequest.QueryDelay { get; set; }
114128
IScriptFields IUpdateDatafeedRequest.ScriptFields { get; set; }
115129
int? IUpdateDatafeedRequest.ScrollSize { get; set; }
130+
int? IUpdateDatafeedRequest.MaximumEmptySearches { get; set; }
116131

117132
/// <inheritdoc />
118133
public UpdateDatafeedDescriptor<TDocument> Aggregations(Func<AggregationContainerDescriptor<TDocument>, IAggregationContainer> aggregationsSelector) =>
@@ -151,5 +166,9 @@ public UpdateDatafeedDescriptor<TDocument> ScriptFields(Func<ScriptFieldsDescrip
151166

152167
/// <inheritdoc />
153168
public UpdateDatafeedDescriptor<TDocument> ScrollSize(int? scrollSize) => Assign(scrollSize, (a, v) => a.ScrollSize = v);
169+
170+
/// <inheritdoc />
171+
public UpdateDatafeedDescriptor<TDocument> MaximumEmptySearches(int? maximumEmptySearches) =>
172+
Assign(maximumEmptySearches, (a, v) => a.MaximumEmptySearches = v);
154173
}
155174
}

src/Nest/XPack/MachineLearning/UpdateDataFeed/UpdateDatafeedResponse.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ public class UpdateDatafeedResponse : ResponseBase
7171
/// </summary>
7272
[DataMember(Name = "scroll_size")]
7373
public int? ScrollSize { get; internal set; }
74-
}
7574

75+
/// <summary>
76+
/// If a real-time datafeed has never seen any data (including during any initial training period) then it will automatically stop
77+
/// itself and close its associated job after this many real-time searches that return no documents. In other words, it will
78+
/// stop after <see cref="Frequency"/> times <see cref="MaximumEmptySearches"/> of real-time operation. If not set then a datafeed
79+
/// with no end time that sees no data will remain started until it is explicitly stopped.
80+
/// </summary>
81+
[DataMember(Name ="max_empty_searches")]
82+
public int? MaximumEmptySearches { get; set; }
83+
}
7684
}

0 commit comments

Comments
 (0)