Skip to content

Commit 384f0e3

Browse files
committed
more examples
1 parent 79aa27f commit 384f0e3

File tree

8 files changed

+146
-1
lines changed

8 files changed

+146
-1
lines changed

docs/reference/data-analysis/aggregations/search-aggregations-metrics-min-aggregation.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ POST /sales/_search?size=0
2525
}
2626
```
2727

28+
% TEST[setup:sales]
29+
2830
Response:
2931

3032
```console-result
@@ -39,6 +41,8 @@ Response:
3941
}
4042
```
4143

44+
% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
45+
4246
As can be seen, the name of the aggregation (`min_price` above) also serves as the key by which the aggregation result can be retrieved from the returned response.
4347

4448
## Script [_script_8]
@@ -69,6 +73,21 @@ POST /sales/_search
6973
}
7074
```
7175

76+
% TEST[setup:sales]
77+
78+
% TEST[s/_search/_search?filter_path=aggregations/]
79+
80+
% [source,console-result]
81+
% --------------------------------------------------
82+
% {
83+
% "aggregations": {
84+
% "min_price": {
85+
% "value": 8.0
86+
% }
87+
% }
88+
% }
89+
% --------------------------------------------------
90+
7291

7392
## Missing value [_missing_value_12]
7493

@@ -88,6 +107,8 @@ POST /sales/_search
88107
}
89108
```
90109

110+
% TEST[setup:sales]
111+
91112
1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `10`.
92113

93114

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ A `sum_bucket` aggregation looks like this in isolation:
2121
}
2222
```
2323

24+
% NOTCONSOLE
25+
2426
$$$sum-bucket-params$$$
2527

2628
| Parameter Name | Description | Required | Default Value |
@@ -58,6 +60,8 @@ POST /sales/_search
5860
}
5961
```
6062

63+
% TEST[setup:sales]
64+
6165
1. `buckets_path` instructs this sum_bucket aggregation that we want the sum of the `sales` aggregation in the `sales_per_month` date histogram.
6266

6367

@@ -105,4 +109,10 @@ And the following may be the response:
105109
}
106110
```
107111

112+
% TESTRESPONSE[s/"took": 11/"took": $body.took/]
113+
114+
% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/]
115+
116+
% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/]
117+
108118

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,84 @@ The filter produces the following tokens:
4545
[ t, th, q, qu, b, br, f, fo, j, ju ]
4646
```
4747

48+
% [source,console-result]
49+
% --------------------------------------------------
50+
% {
51+
% "tokens" : [
52+
% {
53+
% "token" : "t",
54+
% "start_offset" : 0,
55+
% "end_offset" : 3,
56+
% "type" : "<ALPHANUM>",
57+
% "position" : 0
58+
% },
59+
% {
60+
% "token" : "th",
61+
% "start_offset" : 0,
62+
% "end_offset" : 3,
63+
% "type" : "<ALPHANUM>",
64+
% "position" : 0
65+
% },
66+
% {
67+
% "token" : "q",
68+
% "start_offset" : 4,
69+
% "end_offset" : 9,
70+
% "type" : "<ALPHANUM>",
71+
% "position" : 1
72+
% },
73+
% {
74+
% "token" : "qu",
75+
% "start_offset" : 4,
76+
% "end_offset" : 9,
77+
% "type" : "<ALPHANUM>",
78+
% "position" : 1
79+
% },
80+
% {
81+
% "token" : "b",
82+
% "start_offset" : 10,
83+
% "end_offset" : 15,
84+
% "type" : "<ALPHANUM>",
85+
% "position" : 2
86+
% },
87+
% {
88+
% "token" : "br",
89+
% "start_offset" : 10,
90+
% "end_offset" : 15,
91+
% "type" : "<ALPHANUM>",
92+
% "position" : 2
93+
% },
94+
% {
95+
% "token" : "f",
96+
% "start_offset" : 16,
97+
% "end_offset" : 19,
98+
% "type" : "<ALPHANUM>",
99+
% "position" : 3
100+
% },
101+
% {
102+
% "token" : "fo",
103+
% "start_offset" : 16,
104+
% "end_offset" : 19,
105+
% "type" : "<ALPHANUM>",
106+
% "position" : 3
107+
% },
108+
% {
109+
% "token" : "j",
110+
% "start_offset" : 20,
111+
% "end_offset" : 25,
112+
% "type" : "<ALPHANUM>",
113+
% "position" : 4
114+
% },
115+
% {
116+
% "token" : "ju",
117+
% "start_offset" : 20,
118+
% "end_offset" : 25,
119+
% "type" : "<ALPHANUM>",
120+
% "position" : 4
121+
% }
122+
% ]
123+
% }
124+
% --------------------------------------------------
125+
48126

49127
## Add to an analyzer [analysis-edgengram-tokenfilter-analyzer-ex]
50128

docs/reference/elasticsearch/mapping-reference/shape.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ PUT /example
4848
}
4949
```
5050

51+
% TESTSETUP
52+
5153
This mapping definition maps the geometry field to the shape type. The indexer uses single precision floats for the vertex values so accuracy is guaranteed to the same precision as `float` values provided by the java virtual machine approximately (typically 1E-38).
5254

5355

@@ -66,7 +68,7 @@ Shapes can be represented using either the [GeoJSON](http://geojson.org) or [Wel
6668
| `GeometryCollection` | `GEOMETRYCOLLECTION` | `geometrycollection` | A shape collection similar to the`multi*` shapes except that multiple types can coexist (e.g., a Point and a LineString). |
6769
| `N/A` | `BBOX` | `envelope` | A bounding rectangle, or envelope, specified byspecifying only the top left and bottom right points. |
6870

69-
::::{note}
71+
::::{note}
7072
For all types, both the inner `type` and `coordinates` fields are required.
7173

7274
In GeoJSON and WKT, and therefore Elasticsearch, the correct **coordinate order is (X, Y)** within coordinate arrays. This differs from many Geospatial APIs (e.g., `geo_shape`) that typically use the colloquial latitude, longitude (Y, X) ordering.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Suppose you provide this configuration of the `json` processor:
3838
}
3939
```
4040

41+
% NOTCONSOLE
42+
4143
If the following document is processed:
4244

4345
```js
@@ -46,6 +48,8 @@ If the following document is processed:
4648
}
4749
```
4850

51+
% NOTCONSOLE
52+
4953
after the `json` processor operates on it, it will look like:
5054

5155
```js
@@ -57,6 +61,8 @@ after the `json` processor operates on it, it will look like:
5761
}
5862
```
5963

64+
% NOTCONSOLE
65+
6066
If the following configuration is provided, omitting the optional `target_field` setting:
6167

6268
```js
@@ -67,6 +73,8 @@ If the following configuration is provided, omitting the optional `target_field`
6773
}
6874
```
6975

76+
% NOTCONSOLE
77+
7078
then after the `json` processor operates on this document:
7179

7280
```js
@@ -75,6 +83,8 @@ then after the `json` processor operates on this document:
7583
}
7684
```
7785

86+
% NOTCONSOLE
87+
7888
it will look like:
7989

8090
```js
@@ -85,5 +95,7 @@ it will look like:
8595
}
8696
```
8797

98+
% NOTCONSOLE
99+
88100
This illustrates that, unless it is explicitly named in the processor configuration, the `target_field` is the same field provided in the required `field` configuration.
89101

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ $$$set-options$$$
3535
}
3636
```
3737

38+
% NOTCONSOLE
39+
3840
This processor can also be used to copy data from one field to another. For example:
3941

4042
```console
@@ -90,6 +92,8 @@ Result:
9092
}
9193
```
9294

95+
% TESTRESPONSE[s/2019-03-11T21:54:37.909224Z/$body.docs.0.doc._ingest.timestamp/]
96+
9397
This processor can also access array fields using dot notation:
9498

9599
```console
@@ -148,6 +152,8 @@ Result:
148152
}
149153
```
150154

155+
% TESTRESPONSE[s/2023-05-05T16:04:16.456475214Z/$body.docs.0.doc._ingest.timestamp/]
156+
151157
The contents of a field including complex values such as arrays and objects can be copied to another field using `copy_from`:
152158

153159
```console
@@ -199,3 +205,5 @@ Result:
199205
}
200206
```
201207

208+
% TESTRESPONSE[s/2020-09-30T12:55:17.742795Z/$body.docs.0.doc._ingest.timestamp/]
209+

docs/reference/query-languages/query-dsl-geo-shape-query.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ POST /example/_doc?refresh
4141
}
4242
```
4343

44+
% TESTSETUP
45+
4446
The following query will find the point using {{es}}'s `envelope` GeoJSON extension:
4547

4648
```console
@@ -88,6 +90,8 @@ PUT /example_points/_doc/1?refresh
8890
}
8991
```
9092

93+
% TEST[continued]
94+
9195
Using the same query, the documents with matching `geo_point` fields are returned.
9296

9397
```console
@@ -114,6 +118,8 @@ GET /example_points/_search
114118
}
115119
```
116120

121+
% TEST[continued]
122+
117123
```console-result
118124
{
119125
"took" : 17,
@@ -145,6 +151,8 @@ GET /example_points/_search
145151
}
146152
```
147153

154+
% TESTRESPONSE[s/"took" : 17/"took" : $body.took/]
155+
148156

149157
## Pre-indexed shape [_pre_indexed_shape]
150158

docs/reference/query-languages/query-dsl-semantic-query.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ GET my-index-000001/_search
2929
}
3030
```
3131

32+
% TEST[skip: Requires inference endpoints]
33+
3234

3335
## Top-level parameters for `semantic` [semantic-query-params]
3436

@@ -73,6 +75,8 @@ POST my-index/_search
7375
}
7476
```
7577

78+
% TEST[skip: Requires inference endpoints]
79+
7680
You can also use semantic_text as part of [Reciprocal Rank Fusion](/reference/elasticsearch/rest-apis/reciprocal-rank-fusion.md) to make ranking relevant results easier:
7781

7882
```console
@@ -108,3 +112,5 @@ GET my-index/_search
108112
}
109113
```
110114

115+
% TEST[skip: Requires inference endpoints]
116+

0 commit comments

Comments
 (0)