Skip to content

Commit e3fb4bc

Browse files
committed
adding more examples
1 parent d4d9a38 commit e3fb4bc

File tree

9 files changed

+203
-0
lines changed

9 files changed

+203
-0
lines changed

docs/reference/data-analysis/aggregations/search-aggregations-bucket-children-aggregation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ PUT child_example/_doc/1
5353
}
5454
```
5555

56+
% TEST[continued]
57+
5658
Examples of `answer` documents:
5759

5860
```console
@@ -87,6 +89,8 @@ PUT child_example/_doc/3?routing=1&refresh
8789
}
8890
```
8991

92+
% TEST[continued]
93+
9094
The following request can be built that connects the two together:
9195

9296
```console
@@ -118,6 +122,8 @@ POST child_example/_search?size=0
118122
}
119123
```
120124

125+
% TEST[continued]
126+
121127
1. The `type` points to type / mapping with the name `answer`.
122128

123129

@@ -217,6 +223,8 @@ Possible response:
217223
}
218224
```
219225

226+
% TESTRESPONSE[s/"took": 25/"took": $body.took/]
227+
220228
1. The number of question documents with the tag `file-transfer`, `windows-server-2003`, etc.
221229
2. The number of answer documents that are related to question documents with the tag `file-transfer`, `windows-server-2003`, etc.
222230

docs/reference/data-analysis/aggregations/search-aggregations-bucket-daterange-aggregation.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ POST /sales/_search?size=0
3131
}
3232
```
3333

34+
% TEST[setup:sales s/now-10M\/M/10-2015/]
35+
3436
1. < now minus 10 months, rounded down to the start of the month.
3537
2. >= now minus 10 months, rounded down to the start of the month.
3638
@@ -63,6 +65,8 @@ Response:
6365
}
6466
```
6567

68+
% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
69+
6670
::::{warning}
6771
If a format or date value is incomplete, the date range aggregation replaces any missing components with default values. See [Missing date components](/reference/query-languages/query-dsl-range-query.md#missing-date-components).
6872
::::
@@ -99,6 +103,8 @@ POST /sales/_search?size=0
99103
}
100104
```
101105

106+
% TEST[setup:sales]
107+
102108
1. Documents without a value in the `date` field will be added to the "Older" bucket, as if they had a date value of "1976-11-30".
103109

104110

@@ -222,6 +228,8 @@ POST /sales/_search?size=0
222228
}
223229
```
224230

231+
% TEST[setup:sales]
232+
225233
1. This date will be converted to `2016-02-01T00:00:00.000+01:00`.
226234
2. `now/d` will be rounded to the beginning of the day in the CET time zone.
227235

@@ -252,6 +260,8 @@ POST /sales/_search?size=0
252260
}
253261
```
254262

263+
% TEST[setup:sales s/now-10M\/M/10-2015/]
264+
255265
Response:
256266

257267
```console-result
@@ -276,6 +286,8 @@ Response:
276286
}
277287
```
278288

289+
% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
290+
279291
It is also possible to customize the key for each range:
280292

281293
$$$daterange-aggregation-keyed-multiple-keys-example$$$
@@ -299,6 +311,8 @@ POST /sales/_search?size=0
299311
}
300312
```
301313

314+
% TEST[setup:sales]
315+
302316
Response:
303317

304318
```console-result
@@ -327,4 +341,6 @@ Response:
327341
}
328342
```
329343

344+
% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
345+
330346

docs/reference/data-analysis/aggregations/search-aggregations-matrix-stats-aggregation.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ Unlike other metric aggregations, the `matrix_stats` aggregation does not suppor
3535
::::
3636

3737

38+
%
39+
% [source,js]
40+
% --------------------------------------------------
41+
% PUT /statistics/_doc/0
42+
% {"poverty": 24.0, "income": 50000.0}
43+
%
44+
% PUT /statistics/_doc/1
45+
% {"poverty": 13.0, "income": 95687.0}
46+
%
47+
% PUT /statistics/_doc/2
48+
% {"poverty": 69.0, "income": 7890.0}
49+
%
50+
% POST /_refresh
51+
% --------------------------------------------------
52+
% // NOTCONSOLE
53+
% // TESTSETUP
54+
%
55+
3856
The following example demonstrates the use of matrix stats to describe the relationship between income and poverty.
3957

4058
$$$stats-aggregation-example$$$
@@ -52,6 +70,8 @@ GET /_search
5270
}
5371
```
5472

73+
% TEST[s/_search/_search\?filter_path=aggregations/]
74+
5575
The aggregation type is `matrix_stats` and the `fields` setting defines the set of fields (as an array) for computing the statistics. The above request returns the following response:
5676

5777
```console-result
@@ -96,6 +116,10 @@ The aggregation type is `matrix_stats` and the `fields` setting defines the set
96116
}
97117
```
98118

119+
% TESTRESPONSE[s/\.\.\.//]
120+
121+
% TESTRESPONSE[s/: (\-)?[0-9\.E]+/: $body.$_path/]
122+
99123
The `doc_count` field indicates the number of documents involved in the computation of the statistics.
100124

101125
## Multi Value Fields [_multi_value_fields]

docs/reference/data-analysis/aggregations/search-aggregations-pipeline-extended-stats-bucket-aggregation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ A `extended_stats_bucket` aggregation looks like this in isolation:
2323
}
2424
```
2525

26+
% NOTCONSOLE
27+
2628
$$$extended-stats-bucket-params$$$
2729

2830
| Parameter Name | Description | Required | Default Value |
@@ -61,6 +63,8 @@ POST /sales/_search
6163
}
6264
```
6365

66+
% TEST[setup:sales]
67+
6468
1. `bucket_paths` instructs this `extended_stats_bucket` aggregation that we want the calculate stats for the `sales` aggregation in the `sales_per_month` date histogram.
6569

6670

@@ -127,4 +131,10 @@ And the following may be the response:
127131
}
128132
```
129133

134+
% TESTRESPONSE[s/"took": 11/"took": $body.took/]
135+
136+
% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/]
137+
138+
% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/]
139+
130140

docs/reference/data-analysis/text-analysis/analysis-classic-tokenfilter.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,91 @@ The filter produces the following tokens:
3030
[ The, 2, QUICK, Brown, Foxes, jumped, over, the, lazy, dog, bone ]
3131
```
3232

33+
% [source,console-result]
34+
% --------------------------------------------------
35+
% {
36+
% "tokens" : [
37+
% {
38+
% "token" : "The",
39+
% "start_offset" : 0,
40+
% "end_offset" : 3,
41+
% "type" : "<ALPHANUM>",
42+
% "position" : 0
43+
% },
44+
% {
45+
% "token" : "2",
46+
% "start_offset" : 4,
47+
% "end_offset" : 5,
48+
% "type" : "<ALPHANUM>",
49+
% "position" : 1
50+
% },
51+
% {
52+
% "token" : "QUICK",
53+
% "start_offset" : 6,
54+
% "end_offset" : 16,
55+
% "type" : "<ACRONYM>",
56+
% "position" : 2
57+
% },
58+
% {
59+
% "token" : "Brown",
60+
% "start_offset" : 17,
61+
% "end_offset" : 22,
62+
% "type" : "<ALPHANUM>",
63+
% "position" : 3
64+
% },
65+
% {
66+
% "token" : "Foxes",
67+
% "start_offset" : 23,
68+
% "end_offset" : 28,
69+
% "type" : "<ALPHANUM>",
70+
% "position" : 4
71+
% },
72+
% {
73+
% "token" : "jumped",
74+
% "start_offset" : 29,
75+
% "end_offset" : 35,
76+
% "type" : "<ALPHANUM>",
77+
% "position" : 5
78+
% },
79+
% {
80+
% "token" : "over",
81+
% "start_offset" : 36,
82+
% "end_offset" : 40,
83+
% "type" : "<ALPHANUM>",
84+
% "position" : 6
85+
% },
86+
% {
87+
% "token" : "the",
88+
% "start_offset" : 41,
89+
% "end_offset" : 44,
90+
% "type" : "<ALPHANUM>",
91+
% "position" : 7
92+
% },
93+
% {
94+
% "token" : "lazy",
95+
% "start_offset" : 45,
96+
% "end_offset" : 49,
97+
% "type" : "<ALPHANUM>",
98+
% "position" : 8
99+
% },
100+
% {
101+
% "token" : "dog",
102+
% "start_offset" : 50,
103+
% "end_offset" : 55,
104+
% "type" : "<APOSTROPHE>",
105+
% "position" : 9
106+
% },
107+
% {
108+
% "token" : "bone",
109+
% "start_offset" : 56,
110+
% "end_offset" : 60,
111+
% "type" : "<ALPHANUM>",
112+
% "position" : 10
113+
% }
114+
% ]
115+
% }
116+
% --------------------------------------------------
117+
33118

34119
## Add to an analyzer [analysis-classic-tokenfilter-analyzer-ex]
35120

docs/reference/data-analysis/text-analysis/analysis-length-tokenfilter.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,56 @@ The filter produces the following tokens:
4242
[ the, fox, over, the, lazy, dog ]
4343
```
4444

45+
% [source,console-result]
46+
% --------------------------------------------------
47+
% {
48+
% "tokens": [
49+
% {
50+
% "token": "the",
51+
% "start_offset": 0,
52+
% "end_offset": 3,
53+
% "type": "word",
54+
% "position": 0
55+
% },
56+
% {
57+
% "token": "fox",
58+
% "start_offset": 16,
59+
% "end_offset": 19,
60+
% "type": "word",
61+
% "position": 3
62+
% },
63+
% {
64+
% "token": "over",
65+
% "start_offset": 26,
66+
% "end_offset": 30,
67+
% "type": "word",
68+
% "position": 5
69+
% },
70+
% {
71+
% "token": "the",
72+
% "start_offset": 31,
73+
% "end_offset": 34,
74+
% "type": "word",
75+
% "position": 6
76+
% },
77+
% {
78+
% "token": "lazy",
79+
% "start_offset": 35,
80+
% "end_offset": 39,
81+
% "type": "word",
82+
% "position": 7
83+
% },
84+
% {
85+
% "token": "dog",
86+
% "start_offset": 40,
87+
% "end_offset": 43,
88+
% "type": "word",
89+
% "position": 8
90+
% }
91+
% ]
92+
% }
93+
% --------------------------------------------------
94+
4595

4696
## Add to an analyzer [analysis-length-tokenfilter-analyzer-ex]
4797

docs/reference/elasticsearch/mapping-reference/field-alias.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ In some parts of the search request and when requesting field capabilities, fiel
5151
GET trips/_field_caps?fields=route_*,transit_mode
5252
```
5353

54+
% TEST[continued]
55+
5456
## Alias targets [alias-targets]
5557

5658
There are a few restrictions on the target of an alias:
@@ -80,6 +82,8 @@ GET /_search
8082
}
8183
```
8284

85+
% TEST[continued]
86+
8387
Currently only the search and field capabilities APIs will accept and resolve field aliases. Other APIs that accept field names, such as [term vectors](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-termvectors), cannot be used with field aliases.
8488

8589
Finally, some queries, such as `terms`, `geo_shape`, and `more_like_this`, allow for fetching query information from an indexed document. Because field aliases aren’t supported when fetching documents, the part of the query that specifies the lookup path cannot refer to a field by its alias.

docs/reference/ingestion-tools/enrich-processor/append-processor.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ $$$append-options$$$
3232
}
3333
```
3434

35+
% NOTCONSOLE
36+

docs/reference/ingestion-tools/search-connectors/es-sync-rules.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ A sample apartment looks like this in the `.json` format:
235235
}
236236
```
237237

238+
% NOTCONSOLE
239+
238240
The target data set should fulfill the following conditions:
239241

240242
1. Every apartment should have at least **3 bedrooms**
@@ -304,6 +306,8 @@ Let’s assume that the apartment data is stored inside a MongoDB instance. For
304306
]
305307
```
306308

309+
% NOTCONSOLE
310+
307311
To create these advanced sync rules navigate to the sync rules creation dialog and select the *Advanced rules* tab. You can now paste your aggregation pipeline into the input field under `aggregate.pipeline`:
308312

309313
:::{image} ../../../images/sync-rules-paste-aggregation-pipeline.png

0 commit comments

Comments
 (0)