Skip to content

Commit 4385915

Browse files
authored
[DOCS] Add code snippet testing in more ML APIs (#31339)
1 parent 4f9332e commit 4385915

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

x-pack/docs/build.gradle

+16-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ buildRestTests.expectedUnconvertedCandidates = [
4747
'en/watcher/trigger/schedule/yearly.asciidoc',
4848
'en/watcher/troubleshooting.asciidoc',
4949
'en/rest-api/ml/delete-snapshot.asciidoc',
50-
'en/rest-api/ml/forecast.asciidoc',
5150
'en/rest-api/ml/get-bucket.asciidoc',
5251
'en/rest-api/ml/get-job-stats.asciidoc',
5352
'en/rest-api/ml/get-overall-buckets.asciidoc',
@@ -56,7 +55,6 @@ buildRestTests.expectedUnconvertedCandidates = [
5655
'en/rest-api/ml/get-influencer.asciidoc',
5756
'en/rest-api/ml/get-snapshot.asciidoc',
5857
'en/rest-api/ml/post-data.asciidoc',
59-
'en/rest-api/ml/preview-datafeed.asciidoc',
6058
'en/rest-api/ml/revert-snapshot.asciidoc',
6159
'en/rest-api/ml/update-snapshot.asciidoc',
6260
'en/rest-api/watcher/stats.asciidoc',
@@ -296,7 +294,9 @@ setups['farequote_index'] = '''
296294
responsetime:
297295
type: float
298296
airline:
299-
type: keyword
297+
type: keyword
298+
doc_count:
299+
type: integer
300300
'''
301301
setups['farequote_data'] = setups['farequote_index'] + '''
302302
- do:
@@ -306,11 +306,11 @@ setups['farequote_data'] = setups['farequote_index'] + '''
306306
refresh: true
307307
body: |
308308
{"index": {"_id":"1"}}
309-
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000"}
309+
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5}
310310
{"index": {"_id":"2"}}
311-
{"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000"}
311+
{"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23}
312312
{"index": {"_id":"3"}}
313-
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000"}
313+
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42}
314314
'''
315315
setups['farequote_job'] = setups['farequote_data'] + '''
316316
- do:
@@ -332,6 +332,16 @@ setups['farequote_job'] = setups['farequote_data'] + '''
332332
}
333333
}
334334
'''
335+
setups['farequote_datafeed'] = setups['farequote_job'] + '''
336+
- do:
337+
xpack.ml.put_datafeed:
338+
datafeed_id: "datafeed-farequote"
339+
body: >
340+
{
341+
"job_id":"farequote",
342+
"indexes":"farequote"
343+
}
344+
'''
335345
setups['server_metrics_index'] = '''
336346
- do:
337347
indices.create:

x-pack/docs/en/rest-api/ml/forecast.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<titleabbrev>Forecast Jobs</titleabbrev>
66
++++
77

8-
Predict the future behavior of a time series by using historical behavior.
8+
Predicts the future behavior of a time series by using its historical behavior.
99

1010
==== Request
1111

@@ -62,7 +62,7 @@ POST _xpack/ml/anomaly_detectors/total-requests/_forecast
6262
}
6363
--------------------------------------------------
6464
// CONSOLE
65-
// TEST[skip:todo]
65+
// TEST[skip:requires delay]
6666

6767
When the forecast is created, you receive the following results:
6868
[source,js]
@@ -72,7 +72,7 @@ When the forecast is created, you receive the following results:
7272
"forecast_id": "wkCWa2IB2lF8nSE_TzZo"
7373
}
7474
----
75+
// NOTCONSOLE
7576

7677
You can subsequently see the forecast in the *Single Metric Viewer* in {kib}.
77-
//and in the results that you retrieve by using {ml} APIs such as the
78-
//<<ml-get-bucket,get bucket API>> and <<ml-get-record,get records API>>.
78+

x-pack/docs/en/rest-api/ml/preview-datafeed.asciidoc

+12-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ structure of the data that will be passed to the anomaly detection engine.
3131
You must have `monitor_ml`, `monitor`, `manage_ml`, or `manage` cluster
3232
privileges to use this API. For more information, see
3333
{xpack-ref}/security-privileges.html[Security Privileges].
34-
//<<privileges-list-cluster>>.
3534

3635

3736
==== Security Integration
@@ -54,27 +53,30 @@ The following example obtains a preview of the `datafeed-farequote` {dfeed}:
5453
GET _xpack/ml/datafeeds/datafeed-farequote/_preview
5554
--------------------------------------------------
5655
// CONSOLE
57-
// TEST[skip:todo]
56+
// TEST[setup:farequote_datafeed]
5857

5958
The data that is returned for this example is as follows:
6059
[source,js]
6160
----
6261
[
6362
{
64-
"@timestamp": 1454803200000,
65-
"airline": "AAL",
66-
"responsetime": 132.20460510253906
67-
},
68-
{
69-
"@timestamp": 1454803200000,
63+
"time": 1454803200000,
7064
"airline": "JZA",
65+
"doc_count": 5,
7166
"responsetime": 990.4628295898438
7267
},
7368
{
74-
"@timestamp": 1454803200000,
69+
"time": 1454803200000,
7570
"airline": "JBU",
71+
"doc_count": 23,
7672
"responsetime": 877.5927124023438
7773
},
78-
...
74+
{
75+
"time": 1454803200000,
76+
"airline": "KLM",
77+
"doc_count": 42,
78+
"responsetime": 1355.481201171875
79+
}
7980
]
8081
----
82+
// TESTRESPONSE

0 commit comments

Comments
 (0)