Skip to content

Commit e0bc4d5

Browse files
committed
[DOCS] Add code snippet testing in more ML APIs (#31339)
1 parent 4438be1 commit e0bc4d5

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',
@@ -297,7 +295,9 @@ setups['farequote_index'] = '''
297295
responsetime:
298296
type: float
299297
airline:
300-
type: keyword
298+
type: keyword
299+
doc_count:
300+
type: integer
301301
'''
302302
setups['farequote_data'] = setups['farequote_index'] + '''
303303
- do:
@@ -307,11 +307,11 @@ setups['farequote_data'] = setups['farequote_index'] + '''
307307
refresh: true
308308
body: |
309309
{"index": {"_id":"1"}}
310-
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000"}
310+
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5}
311311
{"index": {"_id":"2"}}
312-
{"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000"}
312+
{"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23}
313313
{"index": {"_id":"3"}}
314-
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000"}
314+
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42}
315315
'''
316316
setups['farequote_job'] = setups['farequote_data'] + '''
317317
- do:
@@ -333,6 +333,16 @@ setups['farequote_job'] = setups['farequote_data'] + '''
333333
}
334334
}
335335
'''
336+
setups['farequote_datafeed'] = setups['farequote_job'] + '''
337+
- do:
338+
xpack.ml.put_datafeed:
339+
datafeed_id: "datafeed-farequote"
340+
body: >
341+
{
342+
"job_id":"farequote",
343+
"indexes":"farequote"
344+
}
345+
'''
336346
setups['server_metrics_index'] = '''
337347
- do:
338348
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)