Skip to content

Commit f2c2ae6

Browse files
committed
Fix Watcher Examples in Painless (#45631)
This fixes the mappings and types required to run watcher and other examples. A new set of seat data will be updated and available for download to go with this change.
1 parent ad8ce0d commit f2c2ae6

5 files changed

+21
-9
lines changed

docs/painless/painless-contexts/painless-context-examples.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PUT /seats
4848
"mappings": {
4949
"properties": {
5050
"theatre": { "type": "keyword" },
51-
"play": { "type": "text" },
51+
"play": { "type": "keyword" },
5252
"actors": { "type": "text" },
5353
"row": { "type": "integer" },
5454
"number": { "type": "integer" },
@@ -72,7 +72,7 @@ seat data is indexed.
7272
+
7373
[source,js]
7474
----
75-
curl -XPOST localhost:9200/seats/seat/_bulk?pipeline=seats -H "Content-Type: application/x-ndjson" --data-binary "@/<local-file-path>/seats.json"
75+
curl -XPOST "localhost:9200/seats/_bulk?pipeline=seats" -H "Content-Type: application/x-ndjson" --data-binary "@/<local-file-path>/seats.json"
7676
----
7777
// NOTCONSOLE
7878

docs/painless/painless-contexts/painless-filter-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ all available theatre seats for evening performances that are under $18.
4343

4444
[source,js]
4545
----
46-
GET evening/_search
46+
GET seats/_search
4747
{
4848
"query": {
4949
"bool" : {

docs/painless/painless-contexts/painless-watcher-condition-context.asciidoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The standard <<painless-api-reference, Painless API>> is available.
1818

1919
*Example*
2020

21-
[source,Painless]
21+
[source,js]
2222
----
2323
POST _watcher/watch/_execute
2424
{
@@ -65,6 +65,8 @@ POST _watcher/watch/_execute
6565
}
6666
}
6767
----
68+
// CONSOLE
69+
// TEST[skip: requires setup from other pages]
6870

6971
<1> The Java Stream API is used in the condition. This API allows manipulation of
7072
the elements of the list in a pipeline.
@@ -76,7 +78,7 @@ on the value of the seats sold for the plays in the data set. The script aggrega
7678
the total sold seats for each play and returns true if there is at least one play
7779
that has sold over $50,000.
7880

79-
[source,Painless]
81+
[source,js]
8082
----
8183
POST _watcher/watch/_execute
8284
{
@@ -121,6 +123,8 @@ POST _watcher/watch/_execute
121123
}
122124
}
123125
----
126+
// CONSOLE
127+
// TEST[skip: requires setup from other pages]
124128

125129
This example uses a nearly identical condition as the previous example. The
126130
differences below are subtle and are worth calling out.

docs/painless/painless-contexts/painless-watcher-context-example.asciidoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[source,Painless]
1+
[source,js]
22
----
33
POST _watcher/watch/_execute
44
{
@@ -99,10 +99,12 @@ POST _watcher/watch/_execute
9999
}
100100
}
101101
----
102+
// CONSOLE
103+
// TEST[skip: requires setup from other pages]
102104

103105
The following example shows the use of metadata and transforming dates into a readable format.
104106

105-
[source,Painless]
107+
[source,js]
106108
----
107109
POST _watcher/watch/_execute
108110
{
@@ -155,3 +157,5 @@ POST _watcher/watch/_execute
155157
}
156158
}
157159
----
160+
// CONSOLE
161+
// TEST[skip: requires setup from other pages]

docs/painless/painless-contexts/painless-watcher-transform-context.asciidoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The standard <<painless-api-reference, Painless API>> is available.
1818

1919
*Example*
2020

21-
[source,Painless]
21+
[source,js]
2222
----
2323
POST _watcher/watch/_execute
2424
{
@@ -75,6 +75,8 @@ POST _watcher/watch/_execute
7575
}
7676
}
7777
----
78+
// CONSOLE
79+
// TEST[skip: requires setup from other pages]
7880

7981
<1> The Java Stream API is used in the transform. This API allows manipulation of
8082
the elements of the list in a pipeline.
@@ -86,7 +88,7 @@ the elements of the list in a pipeline.
8688
The following action transform changes each value in the mod_log action into a `String`.
8789
This transform does not change the values in the unmod_log action.
8890

89-
[source,Painless]
91+
[source,js]
9092
----
9193
POST _watcher/watch/_execute
9294
{
@@ -140,6 +142,8 @@ POST _watcher/watch/_execute
140142
}
141143
}
142144
----
145+
// CONSOLE
146+
// TEST[skip: requires setup from other pages]
143147

144148
This example uses the streaming API in a very similar manner. The differences below are
145149
subtle and worth calling out.

0 commit comments

Comments
 (0)