diff --git a/docs/reference/aggregations/pipeline.md b/docs/reference/aggregations/pipeline.md index b1f7386e393fc..963fdb44782c5 100644 --- a/docs/reference/aggregations/pipeline.md +++ b/docs/reference/aggregations/pipeline.md @@ -102,6 +102,7 @@ POST /_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this max_bucket aggregation that we want the maximum value of the `sales` aggregation in the `sales_per_month` date histogram. @@ -146,6 +147,7 @@ POST /_search } } ``` +% TEST[setup:sales] 1. `buckets_path` selects the hats and bags buckets (via `['hat']`/`['bag']``) to use in the script specifically, instead of fetching all the buckets from `sale_type` aggregation @@ -214,6 +216,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. By using `_bucket_count` instead of a metric name, we can filter out `histo` buckets where they contain no buckets for the `categories` aggregation @@ -226,7 +229,7 @@ An alternate syntax is supported to cope with aggregations or metrics which have ```js "buckets_path": "my_percentile[99.9]" ``` - +% NOTCONSOLE ## Dealing with gaps in the data [gap-policy] diff --git a/docs/reference/aggregations/search-aggregations-bucket-adjacency-matrix-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-adjacency-matrix-aggregation.md index c4d72556308a9..aea69f5e5fed2 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-adjacency-matrix-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-adjacency-matrix-aggregation.md @@ -87,7 +87,9 @@ The response contains buckets with document counts for each filter and combinati } } ``` - +% TESTRESPONSE[s/"took": 9/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] ## Parameters [adjacency-matrix-agg-params] diff --git a/docs/reference/aggregations/search-aggregations-bucket-autodatehistogram-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-autodatehistogram-aggregation.md index 4874e4057c668..d909655f6845a 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-autodatehistogram-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-autodatehistogram-aggregation.md @@ -28,6 +28,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] ## Keys [_keys] @@ -54,6 +55,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. Supports expressive date [format pattern](/reference/aggregations/search-aggregations-bucket-daterange-aggregation.md#date-format-pattern) @@ -87,7 +89,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Intervals [_intervals] @@ -182,6 +184,7 @@ UTC is used if no time zone is specified, three 1-hour buckets are returned star } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] If a `time_zone` of `-01:00` is specified, then midnight starts at one hour before midnight UTC: @@ -199,6 +202,7 @@ GET my-index-000001/_search?size=0 } } ``` +% TEST[continued] Now three 1-hour buckets are still returned but the first bucket starts at 11:00pm on 30 September 2015 since that is the local time for the bucket in the specified time zone. @@ -229,6 +233,7 @@ Now three 1-hour buckets are still returned but the first bucket starts at 11:00 } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] 1. The `key_as_string` value represents midnight on each day in the specified time zone. @@ -268,7 +273,7 @@ POST /sales/_search?size=0 } } ``` - +% TEST[setup:sales] ## Missing value [_missing_value] @@ -290,6 +295,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. Documents without a value in the `publish_date` field will fall into the same bucket as documents that have the value `2000-01-01`. diff --git a/docs/reference/aggregations/search-aggregations-bucket-categorize-text-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-categorize-text-aggregation.md index d82dab9798697..b57dc823fa917 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-categorize-text-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-categorize-text-aggregation.md @@ -107,6 +107,7 @@ POST log-messages/_search?filter_path=aggregations } } ``` +% TEST[setup:categorize_text] Response: @@ -160,6 +161,7 @@ POST log-messages/_search?filter_path=aggregations } } ``` +% TEST[setup:categorize_text] 1. The filters to apply to the analyzed tokens. It filters out tokens like `bar_123`. @@ -217,6 +219,7 @@ POST log-messages/_search?filter_path=aggregations } } ``` +% TEST[setup:categorize_text] 1. The filters to apply to the analyzed tokens. It filters out tokens like `bar_123`. 2. Require 11% of token weight to match before adding a message to an existing category rather than creating a new one. @@ -279,6 +282,7 @@ POST log-messages/_search?filter_path=aggregations } } ``` +% TEST[setup:categorize_text] ```console-result { diff --git a/docs/reference/aggregations/search-aggregations-bucket-children-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-children-aggregation.md index 9d860fa8873e2..1adcb92cdd4b6 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-children-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-children-aggregation.md @@ -52,6 +52,7 @@ PUT child_example/_doc/1 ] } ``` +% TEST[continued] Examples of `answer` documents: @@ -86,6 +87,7 @@ PUT child_example/_doc/3?routing=1&refresh "creation_date": "2009-05-05T13:45:37.030" } ``` +% TEST[continued] The following request can be built that connects the two together: @@ -117,6 +119,7 @@ POST child_example/_search?size=0 } } ``` +% TEST[continued] 1. The `type` points to type / mapping with the name `answer`. @@ -216,6 +219,7 @@ Possible response: } } ``` +% TESTRESPONSE[s/"took": 25/"took": $body.took/] 1. The number of question documents with the tag `file-transfer`, `windows-server-2003`, etc. 2. The number of answer documents that are related to question documents with the tag `file-transfer`, `windows-server-2003`, etc. diff --git a/docs/reference/aggregations/search-aggregations-bucket-composite-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-composite-aggregation.md index 03fc0477eb016..6b841cef894e0 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-composite-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-composite-aggregation.md @@ -18,6 +18,62 @@ Unlike the other `multi-bucket` aggregations, you can use the `composite` aggreg The composite buckets are built from the combinations of the values extracted/created for each document and each combination is considered as a composite bucket. + + For example, consider the following document: ```js @@ -26,6 +82,7 @@ For example, consider the following document: "number": [23, 65, 76] } ``` +% NOTCONSOLE Using `keyword` and `number` as source fields for the aggregation results in the following composite buckets: @@ -37,6 +94,7 @@ Using `keyword` and `number` as source fields for the aggregation results in the { "keyword": "bar", "number": 65 } { "keyword": "bar", "number": 76 } ``` +% NOTCONSOLE ## Value sources [_value_sources] @@ -310,6 +368,7 @@ Instead of a single bucket starting at midnight, the above request groups the do } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ::::{note} The start `offset` of each bucket is calculated after `time_zone` adjustments have been made. @@ -513,6 +572,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] ... returns: @@ -545,6 +605,7 @@ GET /_search } } ``` +% TESTRESPONSE[s/\.\.\.//] To get the next set of buckets, resend the same aggregation with the `after` parameter set to the `after_key` value returned in the response. For example, this request uses the `after_key` value provided in the previous response: @@ -709,6 +770,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] ... returns: @@ -767,7 +829,7 @@ GET /_search } } ``` - +% TESTRESPONSE[s/\.\.\.//] ## Pipeline aggregations [search-aggregations-bucket-composite-aggregation-pipeline-aggregations] diff --git a/docs/reference/aggregations/search-aggregations-bucket-correlation-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-correlation-aggregation.md index e553c5654ede2..96bbd60ff101f 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-correlation-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-correlation-aggregation.md @@ -58,6 +58,7 @@ A `bucket_correlation` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE 1. The buckets containing the values to correlate against. 2. The correlation function definition. @@ -116,6 +117,7 @@ POST correlate_latency/_search?size=0&filter_path=aggregations } } ``` +% TEST[setup:correlate_latency] 1. The term buckets containing a range aggregation and the bucket correlation aggregation. Both are utilized to calculate the correlation of the term values with the latency. 2. The range aggregation on the latency field. The ranges were created referencing the percentiles of the latency field. diff --git a/docs/reference/aggregations/search-aggregations-bucket-count-ks-test-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-count-ks-test-aggregation.md index bd9b6b0d65d18..d48c8fed2a132 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-count-ks-test-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-count-ks-test-aggregation.md @@ -37,6 +37,7 @@ A `bucket_count_ks_test` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE 1. The buckets containing the values to test against. 2. The alternatives to calculate. @@ -89,6 +90,7 @@ POST correlate_latency/_search?size=0&filter_path=aggregations } } ``` +% TEST[setup:correlate_latency] 1. The term buckets containing a range aggregation and the bucket correlation aggregation. Both are utilized to calculate the correlation of the term values with the latency. 2. The range aggregation on the latency field. The ranges were created referencing the percentiles of the latency field. diff --git a/docs/reference/aggregations/search-aggregations-bucket-datehistogram-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-datehistogram-aggregation.md index 6ff26774e3ec3..b2a8df9bb1b7d 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-datehistogram-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-datehistogram-aggregation.md @@ -70,6 +70,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] If you attempt to use multiples of calendar units, the aggregation will fail because only singular calendar units are supported: @@ -88,6 +89,8 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] +% TEST[catch:bad_request] ```js { @@ -103,7 +106,7 @@ POST /sales/_search?size=0 } } ``` - +% NOTCONSOLE ## Fixed intervals [fixed_intervals] @@ -150,6 +153,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] But if we try to use a calendar unit that is not supported, such as weeks, we’ll get an exception: @@ -168,6 +172,8 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] +% TEST[catch:bad_request] ```js { @@ -183,7 +189,7 @@ POST /sales/_search?size=0 } } ``` - +% NOTCONSOLE ## Date histogram usage notes [datehistogram-aggregation-notes] @@ -235,6 +241,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. Supports expressive date [format pattern](/reference/aggregations/search-aggregations-bucket-daterange-aggregation.md#date-format-pattern) @@ -267,7 +274,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Time zone [datehistogram-aggregation-time-zone] @@ -335,6 +342,7 @@ If you don’t specify a time zone, UTC is used. This would result in both of th } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] If you specify a `time_zone` of `-01:00`, midnight in that time zone is one hour before midnight UTC: @@ -352,6 +360,7 @@ GET my-index-000001/_search?size=0 } } ``` +% TEST[continued] Now the first document falls into the bucket for 30 September 2015, while the second document falls into the bucket for 1 October 2015: @@ -376,6 +385,7 @@ Now the first document falls into the bucket for 30 September 2015, while the se } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] 1. The `key_as_string` value represents midnight on each day in the specified time zone. @@ -442,6 +452,7 @@ Instead of a single bucket starting at midnight, the above request groups the do } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ::::{note} The start `offset` of each bucket is calculated after `time_zone` adjustments have been made. @@ -470,6 +481,7 @@ $$$datehistogram-aggregation-offset-example-19d$$$ { "key_as_string": "2022-08-20", "key": 1660953600000, "doc_count": 1 } ] ``` +% TESTRESPONSE[skip:no setup made for this example yet] Increasing the offset to `+20d`, each document will appear in a bucket for the previous month, with all bucket keys ending with the same day of the month, as normal. However, further increasing to `+28d`, what used to be a February bucket has now become `"2022-03-01"`. @@ -487,6 +499,7 @@ $$$datehistogram-aggregation-offset-example-28d$$$ { "key_as_string": "2022-07-29", "key": 1659052800000, "doc_count": 1 } ] ``` +% TESTRESPONSE[skip:no setup made for this example yet] If we continue to increase the offset, the 30-day months will also shift into the next month, so that 3 of the 8 buckets have different days than the other five. In fact if we keep going, we will find cases where two documents appear in the same month. Documents that were originally 30 days apart can be shifted into the same 31-day month bucket. @@ -503,6 +516,7 @@ $$$datehistogram-aggregation-offset-example-50d$$$ { "key_as_string": "2022-08-20", "key": 1660953600000, "doc_count": 1 } ] ``` +% TESTRESPONSE[skip:no setup made for this example yet] It is therefore always important when using `offset` with `calendar_interval` bucket sizes to understand the consequences of using offsets larger than the interval size. @@ -534,6 +548,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -563,7 +578,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Scripts [date-histogram-scripts] @@ -596,7 +611,7 @@ POST /sales/_search?size=0 } } ``` - +% TEST[setup:sales] ## Parameters [date-histogram-params] @@ -622,6 +637,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. Documents without a value in the `date` field will fall into the same bucket as documents that have the value `2000-01-01`. @@ -654,6 +670,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -678,6 +695,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The response will contain all the buckets having the relative day of the week as key : 1 for Monday, 2 for Tuesday… 7 for Sunday. diff --git a/docs/reference/aggregations/search-aggregations-bucket-daterange-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-daterange-aggregation.md index 8bfa5e76a3fd2..4434a098f46e1 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-daterange-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-daterange-aggregation.md @@ -30,6 +30,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales s/now-10M\/M/10-2015/] 1. < now minus 10 months, rounded down to the start of the month. 2. >= now minus 10 months, rounded down to the start of the month. @@ -62,6 +63,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ::::{warning} 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/query-dsl-range-query.md#missing-date-components). @@ -98,6 +100,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 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". @@ -221,6 +224,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. This date will be converted to `2016-02-01T00:00:00.000+01:00`. 2. `now/d` will be rounded to the beginning of the day in the CET time zone. @@ -251,6 +255,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales s/now-10M\/M/10-2015/] Response: @@ -275,6 +280,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] It is also possible to customize the key for each range: @@ -298,6 +304,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -326,5 +333,5 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] diff --git a/docs/reference/aggregations/search-aggregations-bucket-diversified-sampler-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-diversified-sampler-aggregation.md index e8483a65571af..91a2ab7fc8806 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-diversified-sampler-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-diversified-sampler-aggregation.md @@ -54,6 +54,7 @@ POST /stackoverflow/_search?size=0 } } ``` +% TEST[setup:stackoverflow] Response: @@ -79,6 +80,8 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/2.213/$body.aggregations.my_unbiased_sample.keywords.buckets.0.score/] 1. 151 documents were sampled in total. 2. The results of the significant_terms aggregation are not skewed by any single author’s quirks because we asked for a maximum of one post from any one author in our sample. @@ -123,6 +126,7 @@ POST /stackoverflow/_search?size=0 } } ``` +% TEST[setup:stackoverflow] Response: @@ -154,7 +158,9 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/2.213/$body.aggregations.my_unbiased_sample.keywords.buckets.0.score/] +% TESTRESPONSE[s/1.34/$body.aggregations.my_unbiased_sample.keywords.buckets.1.score/] ## shard_size [_shard_size] diff --git a/docs/reference/aggregations/search-aggregations-bucket-filter-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-filter-aggregation.md index 47f6754c78e37..edb79c443ff54 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-filter-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-filter-aggregation.md @@ -27,6 +27,7 @@ POST /sales/_search?size=0&filter_path=aggregations } } ``` +% TEST[setup:sales] The previous example calculates the average price of all sales as well as the average price of all T-shirt sales. @@ -61,6 +62,7 @@ POST /sales/_search?size=0&filter_path=aggregations } } ``` +% TEST[setup:sales] Instead of this: @@ -79,7 +81,7 @@ POST /sales/_search?size=0&filter_path=aggregations } } ``` - +% TEST[setup:sales] ## Use the `filters` aggregation for multiple filters [use-filters-agg-for-multiple-filters] @@ -107,6 +109,7 @@ POST /sales/_search?size=0&filter_path=aggregations } } ``` +% TEST[setup:sales] Instead of this: @@ -131,5 +134,5 @@ POST /sales/_search?size=0&filter_path=aggregations } } ``` - +% TEST[setup:sales] diff --git a/docs/reference/aggregations/search-aggregations-bucket-filters-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-filters-aggregation.md index 465361130fe80..92b9b71b42139 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-filters-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-filters-aggregation.md @@ -62,6 +62,9 @@ Response: } } ``` +% TESTRESPONSE[s/"took": 9/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] ## Anonymous filters [anonymous-filters] @@ -85,6 +88,7 @@ GET logs/_search } } ``` +% TEST[continued] The filtered buckets are returned in the same order as provided in the request. The response for this example would be: @@ -108,7 +112,9 @@ The filtered buckets are returned in the same order as provided in the request. } } ``` - +% TESTRESPONSE[s/"took": 4/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] ## `Other` Bucket [other-bucket] @@ -148,6 +154,7 @@ GET logs/_search } } ``` +% TEST[continued] The response would be something like the following: @@ -174,7 +181,9 @@ The response would be something like the following: } } ``` - +% TESTRESPONSE[s/"took": 3/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] ## Non-keyed Response [non-keyed-response] @@ -217,6 +226,7 @@ POST /sales/_search?size=0&filter_path=aggregations } } ``` +% TEST[setup:sales] Response: diff --git a/docs/reference/aggregations/search-aggregations-bucket-frequent-item-sets-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-frequent-item-sets-aggregation.md index 39e37850bc067..38fd9a8a39d87 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-frequent-item-sets-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-frequent-item-sets-aggregation.md @@ -26,6 +26,7 @@ A `frequent_item_sets` aggregation looks like this in isolation: ] } ``` +% NOTCONSOLE | | | | | | --- | --- | --- | --- | @@ -104,12 +105,14 @@ POST /kibana_sample_data_ecommerce/_async_search } } ``` +% TEST[skip:setup kibana sample data] The response of the API call above contains an identifier (`id`) of the async search request. You can use the identifier to retrieve the search results: ```console GET /_async_search/ ``` +% TEST[skip:setup kibana sample data] The API returns a response similar to the following one: @@ -162,6 +165,7 @@ The API returns a response similar to the following one: } } ``` +% TEST[skip:setup kibana sample data] 1. The array of returned item sets. 2. The `key` object contains one item set. In this case, it consists of two values of the `category.keyword` field and one value of the `geoip.city_name`. @@ -199,6 +203,7 @@ POST /kibana_sample_data_ecommerce/_async_search } } ``` +% TEST[skip:setup kibana sample data] The result will only show item sets that created from documents matching the filter, namely purchases in Europe. Using `filter`, the calculated `support` still takes all purchases into acount. That’s different than specifying a query at the top-level, in which case `support` gets calculated only from purchases in Europe. @@ -244,6 +249,7 @@ GET kibana_sample_data_ecommerce/_search } } ``` +% TEST[skip:setup kibana sample data] The API returns a response similar to the following one: @@ -305,6 +311,7 @@ The API returns a response similar to the following one: } } ``` +% TEST[skip:setup kibana sample data] The response shows the categories that customers purchase from most frequently together, the location of the customers who tend to buy items from these categories, and the most frequent price ranges of these purchases. diff --git a/docs/reference/aggregations/search-aggregations-bucket-geodistance-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-geodistance-aggregation.md index c4e98242a9e43..7c2d37fa797b6 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-geodistance-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-geodistance-aggregation.md @@ -85,6 +85,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] The specified field must be of type `geo_point` (which can only be set explicitly in the mappings). And it can also hold an array of `geo_point` fields, in which case all will be taken into account during aggregation. The origin point can accept all formats supported by the [`geo_point` type](/reference/elasticsearch/mapping-reference/geo-point.md): @@ -113,6 +114,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] 1. The distances will be computed in kilometers @@ -139,6 +141,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] ## Keyed Response [_keyed_response_2] @@ -163,6 +166,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] Response: @@ -191,6 +195,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] It is also possible to customize the key for each range: @@ -213,6 +218,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] Response: @@ -241,5 +247,5 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] diff --git a/docs/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md index 7a749c97ed8b6..5d36de75630cc 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md @@ -89,7 +89,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## High-precision requests [_high_precision_requests] @@ -122,6 +122,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] The geohashes returned by the `geohash_grid` aggregation can be also used for zooming in. To zoom into the first geohash `u17` returned in the previous example, it should be specified as both `top_left` and `bottom_right` corner: @@ -150,6 +151,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] ```console-result { @@ -177,6 +179,7 @@ POST /museums/_search?size=0 } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] For "zooming in" on the system that don’t support geohashes, the bucket keys should be translated into bounding boxes using one of available geohash libraries. For example, for javascript the [node-geohash](https://github.com/sunng87/node-geohash) library can be used: @@ -187,7 +190,7 @@ var geohash = require('ngeohash'); // [ minlat, minlon, maxlat, maxlon] var bbox = geohash.decode_bbox('u17'); ``` - +% NOTCONSOLE ## Requests with additional bounding box filtering [_requests_with_additional_bounding_box_filtering] @@ -212,6 +215,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] ```console-result { @@ -236,7 +240,7 @@ POST /museums/_search?size=0 } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## Cell dimensions at the equator [_cell_dimensions_at_the_equator] diff --git a/docs/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md index 63064e2ab342b..684d0eaeb7cbd 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md @@ -84,7 +84,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## High-precision requests [geohexgrid-high-precision] @@ -117,6 +117,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] Response: @@ -146,7 +147,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## Requests with additional bounding box filtering [geohexgrid-addtl-bounding-box-filtering] @@ -171,6 +172,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] Response: @@ -197,7 +199,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ### Aggregating `geo_shape` fields [geohexgrid-aggregating-geo-shape] diff --git a/docs/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md index 69ec49dd1a954..986466458cd4c 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md @@ -89,7 +89,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## High-precision requests [geotilegrid-high-precision] @@ -122,6 +122,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] Response: @@ -151,7 +152,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## Requests with additional bounding box filtering [geotilegrid-addtl-bounding-box-filtering] @@ -176,6 +177,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] Response: @@ -202,7 +204,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ### Aggregating `geo_shape` fields [geotilegrid-aggregating-geo-shape] diff --git a/docs/reference/aggregations/search-aggregations-bucket-global-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-global-aggregation.md index 85ce812ea0502..42de8a6a7cfe9 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-global-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-global-aggregation.md @@ -35,6 +35,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. The `global` aggregation has an empty body 2. The sub-aggregations that are registered for this `global` aggregation @@ -60,6 +61,7 @@ The response for the above aggregation: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] 1. The number of documents that were aggregated (in our case, all documents within the search context) 2. The average price of all products in the index diff --git a/docs/reference/aggregations/search-aggregations-bucket-histogram-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-histogram-aggregation.md index 31cb382baec18..01901c1ee9708 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-histogram-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-histogram-aggregation.md @@ -34,6 +34,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] And the following may be the response: @@ -68,6 +69,7 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Minimum document count [_minimum_document_count] @@ -89,6 +91,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -119,6 +122,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] $$$search-aggregations-bucket-histogram-aggregation-extended-bounds$$$ By default the `histogram` returns all the buckets within the range of the data itself, that is, the documents with the smallest values (on which with histogram) will determine the min bucket (the bucket with the smallest key) and the documents with the highest values will determine the max bucket (the bucket with the highest key). Often, when requesting empty buckets, this causes a confusion, specifically, when the data is also filtered. @@ -155,6 +159,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] When aggregating ranges, buckets are based on the values of the returned documents. This means the response may include buckets outside of a query’s range. For example, if your query looks for values greater than 100, and you have a range covering 50 to 150, and an interval of 50, that document will land in 3 buckets - 50, 100, and 150. In general, it’s best to think of the query and aggregation steps as independent - the query selects a set of documents, and then the aggregation buckets those documents without regard to how they were selected. See [note on bucketing range fields](/reference/aggregations/search-aggregations-bucket-range-field-note.md) for more information and an example. @@ -185,6 +190,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] In this example even though the range specified in the query is up to 500, the histogram will only have 2 buckets starting at 100 and 150. All other buckets will be omitted even if documents that should go to this buckets are present in the results. @@ -221,6 +227,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -255,7 +262,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Missing value [_missing_value_2] @@ -277,6 +284,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. Documents without a value in the `quantity` field will fall into the same bucket as documents that have the value `0`. @@ -367,6 +375,7 @@ The `histogram` aggregation will sum the counts of each interval computed based } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ::::{important} Histogram aggregation is a bucket aggregation, which partitions documents into buckets rather than calculating metrics over fields like metrics aggregations do. Each bucket represents a collection of documents which sub-aggregations can run on. On the other hand, a histogram field is a pre-aggregated field representing multiple values inside a single field: buckets of numerical data and a count of items/documents for each bucket. This mismatch between the histogram aggregations expected input (expecting raw documents) and the histogram field (that provides summary information) limits the outcome of the aggregation to only the doc counts for each bucket. diff --git a/docs/reference/aggregations/search-aggregations-bucket-ipprefix-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-ipprefix-aggregation.md index f15f177f6d5e9..e30045c0c7009 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-ipprefix-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-ipprefix-aggregation.md @@ -44,6 +44,7 @@ POST /network-traffic/_bulk?refresh {"index":{"_id":8}} {"ipv4":"192.168.3.107","ipv6":"2001:db8:a4f8:114f:6001:0:12:7307"} ``` +% TESTSETUP The following aggregation groups documents into buckets. Each bucket identifies a different sub-network. The sub-network is calculated by applying a netmask with prefix length of `24` to each IP address in the `ipv4` field: @@ -63,6 +64,7 @@ GET /network-traffic/_search } } ``` +% TEST Response: @@ -99,6 +101,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] To aggregate IPv6 addresses, set `is_ipv6` to `true`. @@ -119,6 +122,7 @@ GET /network-traffic/_search } } ``` +% TEST If `is_ipv6` is `true`, the response doesn’t include a `netmask` for each bucket. @@ -152,7 +156,7 @@ If `is_ipv6` is `true`, the response doesn’t include a `netmask` for each buck } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Parameters [ip-prefix-agg-params] @@ -216,6 +220,7 @@ GET /network-traffic/_search } } ``` +% TEST Response: @@ -249,7 +254,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Append the prefix length to the IP address key [ipprefix-agg-append-prefix-length] @@ -274,6 +279,7 @@ GET /network-traffic/_search } } ``` +% TEST Response: @@ -310,7 +316,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Minimum document count [ipprefix-agg-min-doc-count] @@ -333,6 +339,7 @@ GET /network-traffic/_search } } ``` +% TEST Response: @@ -362,5 +369,5 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] diff --git a/docs/reference/aggregations/search-aggregations-bucket-iprange-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-iprange-aggregation.md index c385850cf481a..6f12d77fa39c7 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-iprange-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-iprange-aggregation.md @@ -30,6 +30,7 @@ GET /ip_addresses/_search } } ``` +% TEST[setup:iprange] Response: @@ -55,6 +56,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] IP ranges can also be defined as CIDR masks: @@ -77,6 +79,7 @@ GET /ip_addresses/_search } } ``` +% TEST[setup:iprange] Response: @@ -104,6 +107,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Keyed Response [_keyed_response_3] @@ -129,6 +133,7 @@ GET /ip_addresses/_search } } ``` +% TEST[setup:iprange] Response: @@ -152,6 +157,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] It is also possible to customize the key for each range: @@ -175,6 +181,7 @@ GET /ip_addresses/_search } } ``` +% TEST[setup:iprange] Response: @@ -198,5 +205,5 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] diff --git a/docs/reference/aggregations/search-aggregations-bucket-missing-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-missing-aggregation.md index b2e02b12f1ef7..7e8d2c4acdc00 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-missing-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-missing-aggregation.md @@ -23,6 +23,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] In the above example, we get the total number of products that do not have a price. @@ -38,4 +39,4 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] diff --git a/docs/reference/aggregations/search-aggregations-bucket-multi-terms-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-multi-terms-aggregation.md index 5b16f0581f839..4147edb1c1f86 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-multi-terms-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-multi-terms-aggregation.md @@ -11,6 +11,42 @@ A multi-bucket value source based aggregation where buckets are dynamically buil The multi_term aggregations are the most useful when you need to sort by a number of document or a metric aggregation on a composite key and get top N results. If sorting is not required and all values are expected to be retrieved using nested terms aggregation or [`composite aggregations`](/reference/aggregations/search-aggregations-bucket-composite-aggregation.md) will be a faster and more memory efficient solution. + + Example: $$$multi-terms-aggregation-example$$$ @@ -31,6 +67,7 @@ GET /products/_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] 1. `multi_terms` aggregation can work with the same field types as a [`terms aggregation`](/reference/aggregations/search-aggregations-bucket-terms-aggregation.md#search-aggregations-bucket-terms-aggregation-order) and supports most of the terms aggregation parameters. @@ -82,6 +119,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] 1. an upper bound of the error on the document counts for each term, see < 2. when there are lots of unique terms, Elasticsearch only returns the top terms; this number is the sum of the document counts for all buckets that are not part of the response @@ -148,6 +186,7 @@ GET /products/_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -188,7 +227,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\.//] ## Missing value [_missing_value_3] @@ -216,6 +255,7 @@ GET /products/_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -272,6 +312,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] 1. Documents without a value in the `product` field will fall into the same bucket as documents that have the value `Product Z`. @@ -320,6 +361,7 @@ GET /products/_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] ```console-result { @@ -378,5 +420,5 @@ GET /products/_search } } ``` - +% TESTRESPONSE[s/\.\.\.//] diff --git a/docs/reference/aggregations/search-aggregations-bucket-nested-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-nested-aggregation.md index b1f03cb0bba73..56382739141c5 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-nested-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-nested-aggregation.md @@ -55,6 +55,7 @@ PUT /products/_doc/0?refresh ] } ``` +% TEST[continued] 1. We are using a dynamic mapping for the `name` attribute. @@ -85,6 +86,8 @@ GET /products/_search?size=0 } } ``` +% TEST[s/size=0/size=0&filter_path=aggregations/] +% TEST[continued] As you can see above, the nested aggregation requires the `path` of the nested documents within the top level documents. Then one can define any type of aggregation over these nested documents. @@ -103,6 +106,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] You can use a [`filter`](/reference/aggregations/search-aggregations-bucket-filter-aggregation.md) sub-aggregation to return results for a specific reseller. @@ -145,6 +149,8 @@ GET /products/_search?size=0 } } ``` +% TEST[s/size=0/size=0&filter_path=aggregations/] +% TEST[continued] The search returns: @@ -164,4 +170,4 @@ The search returns: } } ``` - +% TESTRESPONSE[s/\.\.\.//] diff --git a/docs/reference/aggregations/search-aggregations-bucket-parent-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-parent-aggregation.md index 2186ef734b9c6..9a37668745a16 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-parent-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-parent-aggregation.md @@ -52,6 +52,7 @@ PUT parent_example/_doc/1 ] } ``` +% TEST[continued] Examples of `answer` documents: @@ -86,6 +87,7 @@ PUT parent_example/_doc/3?routing=1&refresh "creation_date": "2009-05-05T13:45:37.030" } ``` +% TEST[continued] The following request can be built that connects the two together: @@ -117,6 +119,7 @@ POST parent_example/_search?size=0 } } ``` +% TEST[continued] 1. The `type` points to type / mapping with the name `answer`. @@ -203,6 +206,7 @@ Possible response: } } ``` +% TESTRESPONSE[s/"took": 9/"took": $body.took/] 1. The number of answer documents with the tag `Sam`, `Troll`, etc. 2. The number of question documents that are related to answer documents with the tag `Sam`, `Troll`, etc. diff --git a/docs/reference/aggregations/search-aggregations-bucket-range-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-range-aggregation.md index c28747d411b89..5c22b0d043dd9 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-range-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-range-aggregation.md @@ -30,6 +30,8 @@ GET sales/_search } } ``` +% TEST[setup:sales] +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -60,6 +62,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] ## Keyed Response [_keyed_response_4] @@ -85,6 +88,8 @@ GET sales/_search } } ``` +% TEST[setup:sales] +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -112,6 +117,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] It is also possible to customize the key for each range: @@ -135,6 +141,8 @@ GET sales/_search } } ``` +% TEST[setup:sales] +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -162,7 +170,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\.//] ## Script [_script] @@ -200,7 +208,8 @@ GET sales/_search } } ``` - +% TEST[setup:sales] +% TEST[s/_search/_search\?filter_path=aggregations/] ## Sub Aggregations [_sub_aggregations_2] @@ -230,6 +239,8 @@ GET sales/_search } } ``` +% TEST[setup:sales] +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -281,7 +292,7 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\.//] ## Histogram fields [search-aggregations-bucket-range-aggregation-histogram-fields] @@ -380,6 +391,7 @@ The `range` aggregation will sum the counts of each range computed based on the } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ::::{important} Range aggregation is a bucket aggregation, which partitions documents into buckets rather than calculating metrics over fields like metrics aggregations do. Each bucket represents a collection of documents which sub-aggregations can run on. On the other hand, a histogram field is a pre-aggregated field representing multiple values inside a single field: buckets of numerical data and a count of items/documents for each bucket. This mismatch between the range aggregations expected input (expecting raw documents) and the histogram field (that provides summary information) limits the outcome of the aggregation to only the doc counts for each bucket. diff --git a/docs/reference/aggregations/search-aggregations-bucket-range-field-note.md b/docs/reference/aggregations/search-aggregations-bucket-range-field-note.md index 9541b77c55ed7..2a937d34bced2 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-range-field-note.md +++ b/docs/reference/aggregations/search-aggregations-bucket-range-field-note.md @@ -40,6 +40,7 @@ PUT range_index/_doc/1?refresh } } ``` +% TESTSETUP The range is wider than the interval in the following aggregation, and thus the document will land in multiple buckets. @@ -84,6 +85,7 @@ Since the interval is `5` (and the offset is `0` by default), we expect buckets } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] A document cannot exist partially in a bucket; For example, the above document cannot count as one-third in each of the above three buckets. In this example, since the document’s range landed in multiple buckets, the full value of that document would also be counted in any sub-aggregations for each bucket as well. @@ -170,6 +172,7 @@ Even though the query only considers days in November, the aggregation generates } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] Depending on the use case, a `CONTAINS` query could limit the documents to only those that fall entirely in the queried range. In this example, the one document would not be included and the aggregation would be empty. Filtering the buckets after the aggregation is also an option, for use cases where the document should be counted but the out of bounds data can be safely ignored. diff --git a/docs/reference/aggregations/search-aggregations-bucket-rare-terms-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-rare-terms-aggregation.md index 07ac4e2c8f916..49884b7ce85f6 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-rare-terms-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-rare-terms-aggregation.md @@ -11,6 +11,49 @@ A multi-bucket value source based aggregation which finds "rare" terms — terms ## Syntax [_syntax_3] + + A `rare_terms` aggregation looks like this in isolation: ```js @@ -21,6 +64,7 @@ A `rare_terms` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE | | | | | | --- | --- | --- | --- | @@ -48,6 +92,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -66,6 +111,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] In this example, the only bucket that we see is the "swing" bucket, because it is the only term that appears in one document. If we increase the `max_doc_count` to `2`, we’ll see some more buckets: @@ -84,6 +130,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] This now shows the "jazz" term which has a `doc_count` of 2": @@ -106,7 +153,7 @@ This now shows the "jazz" term which has a `doc_count` of 2": } } ``` - +% TESTRESPONSE[s/\.\.\.//] ## Maximum document count [search-aggregations-bucket-rare-terms-aggregation-max-doc-count] diff --git a/docs/reference/aggregations/search-aggregations-bucket-reverse-nested-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-reverse-nested-aggregation.md index 5282f0d491723..2fd09b0081fd9 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-reverse-nested-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-reverse-nested-aggregation.md @@ -40,6 +40,14 @@ PUT /issues The following aggregations will return the top commenters' username that have commented and per top commenter the top tags of the issues the user has commented on: + + ```console GET /issues/_search { @@ -74,6 +82,8 @@ GET /issues/_search } } ``` +% TEST[continued] +% TEST[s/_search/_search\?filter_path=aggregations/] As you can see above, the `reverse_nested` aggregation is put in to a `nested` aggregation as this is the only place in the dsl where the `reverse_nested` aggregation can be used. Its sole purpose is to join back to a parent doc higher up in the nested structure. @@ -116,4 +126,4 @@ Possible response snippet: } } ``` - +% TESTRESPONSE[s/\.\.\.//] diff --git a/docs/reference/aggregations/search-aggregations-bucket-sampler-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-sampler-aggregation.md index 4fa9ef8b27916..e9a1d71b9ab5e 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-sampler-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-sampler-aggregation.md @@ -43,6 +43,7 @@ POST /stackoverflow/_search?size=0 } } ``` +% TEST[setup:stackoverflow] Response: @@ -74,6 +75,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] 1. 200 documents were sampled in total. The cost of performing the nested significant_terms aggregation was therefore limited rather than unbounded. @@ -101,6 +103,7 @@ POST /stackoverflow/_search?size=0 } } ``` +% TEST[setup:stackoverflow] Response: @@ -135,6 +138,9 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/0.02777/$body.aggregations.low_quality_keywords.buckets.0.score/] +% TESTRESPONSE[s/0.0069/$body.aggregations.low_quality_keywords.buckets.2.score/] ## shard_size [_shard_size_2] diff --git a/docs/reference/aggregations/search-aggregations-bucket-significantterms-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-significantterms-aggregation.md index 0ac394bb600da..a446a18f0ac24 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-significantterms-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-significantterms-aggregation.md @@ -21,6 +21,42 @@ In all these cases the terms being selected are not simply the most popular term In the simplest case, the *foreground* set of interest is the search results matched by a query and the *background* set used for statistical comparisons is the index or indices from which the results were gathered. + + Example: $$$significantterms-aggregation-example$$$ @@ -38,6 +74,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -61,6 +98,8 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] +% TESTRESPONSE[s/: (0\.)?[0-9]+/: $body.$_path/] When querying an index of all crimes from all police forces, what these results show is that the British Transport Police force stand out as a force dealing with a disproportionately large number of bicycle thefts. Ordinarily, bicycle thefts represent only 1% of crimes (66799/5064554) but for the British Transport Police, who handle crime on railways and stations, 7% of crimes (3640/47347) is a bike theft. This is a significant seven-fold increase in frequency and so this anomaly was highlighted as the top crime type. @@ -92,6 +131,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] Response: @@ -142,6 +182,9 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] +% TESTRESPONSE[s/: (0\.)?[0-9]+/: $body.$_path/] +% TESTRESPONSE[s/: "[^"]*"/: $body.$_path/] Now we have anomaly detection for each of the police forces using a single request. @@ -256,6 +299,7 @@ The JLH score can be used as a significance score by adding the parameter "jlh": { } ``` +% NOTCONSOLE The scores are derived from the doc frequencies in *foreground* and *background* sets. The *absolute* change in popularity (foregroundPercent - backgroundPercent) would favor common terms whereas the *relative* change in popularity (foregroundPercent/ backgroundPercent) would favor rare terms. Rare vs common is essentially a precision vs recall balance and so the absolute and relative changes are multiplied to provide a sweet spot between precision and recall. @@ -269,6 +313,7 @@ Mutual information as described in "Information Retrieval", Manning et al., Chap "include_negatives": true } ``` +% NOTCONSOLE Mutual information does not differentiate between terms that are descriptive for the subset or for documents outside the subset. The significant terms therefore can contain terms that appear more or less frequent in the subset than outside the subset. To filter out the terms that appear less often in the subset than in documents outside the subset, `include_negatives` can be set to `false`. @@ -277,7 +322,7 @@ Per default, the assumption is that the documents in the bucket are also contain ```js "background_is_superset": false ``` - +% NOTCONSOLE ### Chi square [_chi_square] @@ -287,6 +332,7 @@ Chi square as described in "Information Retrieval", Manning et al., Chapter 13.5 "chi_square": { } ``` +% NOTCONSOLE Chi square behaves like mutual information and can be configured with the same parameters `include_negatives` and `background_is_superset`. @@ -299,6 +345,7 @@ Google normalized distance as described in ["The Google Similarity Distance", Ci "gnd": { } ``` +% NOTCONSOLE `gnd` also accepts the `background_is_superset` parameter. @@ -382,7 +429,7 @@ GET /_search } } ``` - +% TEST[s/_search/_search?size=0/] ### Percentage [_percentage] @@ -397,7 +444,7 @@ It would be hard for a seasoned boxer to win a championship if the prize was awa "percentage": { } ``` - +% NOTCONSOLE ### Which one is best? [_which_one_is_best] @@ -420,6 +467,7 @@ Customized scores can be implemented via a script: } } ``` +% NOTCONSOLE Scripts can be inline (as in above example), indexed or stored on disk. For details on the options, see [script documentation](docs-content://explore-analyze/scripting.md). diff --git a/docs/reference/aggregations/search-aggregations-bucket-significanttext-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-significanttext-aggregation.md index 6175926e80023..2e240b1c7b705 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-significanttext-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-significanttext-aggregation.md @@ -51,6 +51,7 @@ GET news/_search } } ``` +% TEST[setup:news] Response: @@ -79,6 +80,7 @@ Response: } } ``` +% TESTRESPONSE[skip:historically skipped] The results show that "h5n1" is one of several terms strongly associated with bird flu. It only occurs 5 times in our index as a whole (see the `bg_count`) and yet 4 of these were lucky enough to appear in our 100 document sample of "bird flu" results. That suggests a significant word and one which the user can potentially add to their search. @@ -124,6 +126,7 @@ First let’s look at an unfiltered real-world example using the [Signal media d } ``` +% NOTCONSOLE The uncleansed documents have thrown up some odd-looking terms that are, on the face of it, statistically correlated with appearances of our search term "elasticsearch" e.g. "pozmantier". We can drill down into examples of these documents to see why pozmantier is connected using this query: @@ -148,6 +151,7 @@ GET news/_search } } ``` +% TEST[setup:news] The results show a series of very similar news articles about a judging panel for a number of tech projects: @@ -184,6 +188,7 @@ The results show a series of very similar news articles about a judging panel fo }, ... ``` +% NOTCONSOLE Mike Pozmantier was one of many judges on a panel and elasticsearch was used in one of many projects being judged. @@ -218,6 +223,7 @@ GET news/_search } } ``` +% TEST[setup:news] The results from analysing our deduplicated text are obviously of higher quality to anyone familiar with the elastic stack: @@ -254,6 +260,7 @@ The results from analysing our deduplicated text are obviously of higher quality } } ``` +% NOTCONSOLE Mr Pozmantier and other one-off associations with elasticsearch no longer appear in the aggregation results as a consequence of copy-and-paste operations or other forms of mechanical repetition. @@ -366,6 +373,7 @@ GET news/_search } } ``` +% TEST[setup:news] The above filter would help focus in on terms that were peculiar to the city of Madrid rather than revealing terms like "Spanish" that are unusual in the full index’s worldwide context but commonplace in the subset of documents containing the word "Spain". @@ -399,7 +407,7 @@ GET news/_search } } ``` - +% TEST[setup:news] ### Filtering Values [_filtering_values_3] diff --git a/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation.md index 598d8f7617520..e02e66649b520 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation.md @@ -9,6 +9,48 @@ mapped_pages: A multi-bucket value source based aggregation where buckets are dynamically built - one per unique value. + + Example: $$$terms-aggregation-example$$$ @@ -23,6 +65,7 @@ GET /_search } } ``` +% TEST[s/_search/_search?filter_path=aggregations/] Response: @@ -51,6 +94,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\.//] 1. an upper bound of the error on the document counts for each term, see [below](#terms-agg-doc-count-error) 2. when there are lots of unique terms, Elasticsearch only returns the top terms; this number is the sum of the document counts for all buckets that are not part of the response @@ -122,6 +166,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] These errors can only be calculated in this way when the terms are ordered by descending document count. When the aggregation is ordered by the terms values themselves (either ascending or descending) there is no error in the document count since if a shard does not return a particular term which appears in the results from another shard, it must not have that term in its index. When the aggregation is either sorted by a sub aggregation or in order of ascending document count, the error in the document counts cannot be determined and is given a value of -1 to indicate this. @@ -419,6 +464,7 @@ Which will look like: ... } ``` +% TESTRESPONSE[s/\.\.\./"took": "$body.took", "timed_out": false, "_shards": "$body._shards", "hits": "$body.hits"/] This is a little slower because the runtime field has to access two fields instead of one and because there are some optimizations that work on non-runtime `keyword` fields that we have to give up for for runtime `keyword` fields. If you need the speed, you can index the `normalized_genre` field. diff --git a/docs/reference/aggregations/search-aggregations-bucket-time-series-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-time-series-aggregation.md index 24bce3368a67f..176a995288799 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-time-series-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-time-series-aggregation.md @@ -33,6 +33,7 @@ PUT /my-time-series-index-0/_bulk { "index": {}} { "key": "b", "val": 3, "@timestamp": "2022-01-02T00:00:00Z" } ``` +% NOTCONSOLE To perform a time series aggregation, specify "time_series" as the aggregation type. When the boolean "keyed" is true, each bucket is given a unique key. @@ -48,6 +49,7 @@ GET /_search } } ``` +% NOTCONSOLE This will return all results in the time series, however a more typical query will use sub aggregations to reduce the date returned to something more relevant. diff --git a/docs/reference/aggregations/search-aggregations-bucket-variablewidthhistogram-aggregation.md b/docs/reference/aggregations/search-aggregations-bucket-variablewidthhistogram-aggregation.md index 0c6e470838882..25b644ad761b9 100644 --- a/docs/reference/aggregations/search-aggregations-bucket-variablewidthhistogram-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-bucket-variablewidthhistogram-aggregation.md @@ -29,6 +29,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -55,6 +56,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ::::{important} This aggregation cannot currently be nested under any aggregation that collects from more than a single bucket. diff --git a/docs/reference/aggregations/search-aggregations-change-point-aggregation.md b/docs/reference/aggregations/search-aggregations-change-point-aggregation.md index 178a5a7a3e904..7bc038e17ad50 100644 --- a/docs/reference/aggregations/search-aggregations-change-point-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-change-point-aggregation.md @@ -31,6 +31,7 @@ A `change_point` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE 1. The buckets containing the values to test against. @@ -88,6 +89,7 @@ GET kibana_sample_data_logs/_search } } ``` +% NOTCONSOLE 1. A date histogram aggregation that creates buckets with one day long interval. 2. A sibling aggregation of the `date` aggregation that calculates the average value of the `bytes` field within every bucket. @@ -113,6 +115,7 @@ The request returns a response that is similar to the following: } } ``` +% NOTCONSOLE 1. The bucket key that is the change point. 2. The number of documents in that bucket. diff --git a/docs/reference/aggregations/search-aggregations-matrix-stats-aggregation.md b/docs/reference/aggregations/search-aggregations-matrix-stats-aggregation.md index a3939ae956d4f..7e799aad9fa46 100644 --- a/docs/reference/aggregations/search-aggregations-matrix-stats-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-matrix-stats-aggregation.md @@ -37,6 +37,19 @@ Unlike other metric aggregations, the `matrix_stats` aggregation does not suppor The following example demonstrates the use of matrix stats to describe the relationship between income and poverty. + + $$$stats-aggregation-example$$$ ```console @@ -51,6 +64,7 @@ GET /_search } } ``` +% TEST[s/_search/_search\?filter_path=aggregations/] 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: @@ -95,6 +109,8 @@ The aggregation type is `matrix_stats` and the `fields` setting defines the set } } ``` +% TESTRESPONSE[s/\.\.\.//] +% TESTRESPONSE[s/: (\-)?[0-9\.E]+/: $body.$_path/] The `doc_count` field indicates the number of documents involved in the computation of the statistics. diff --git a/docs/reference/aggregations/search-aggregations-metrics-avg-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-avg-aggregation.md index 2c0c0a0a58dbb..27fa150f646ec 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-avg-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-avg-aggregation.md @@ -19,6 +19,7 @@ POST /exams/_search?size=0 } } ``` +% TEST[setup:exams] The above aggregation computes the average grade over all documents. The aggregation type is `avg` and the `field` setting defines the numeric field of the documents the average will be computed on. The above will return the following: @@ -32,6 +33,7 @@ The above aggregation computes the average grade over all documents. The aggrega } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The name of the aggregation (`avg_grade` above) also serves as the key by which the aggregation result can be retrieved from the returned response. @@ -62,7 +64,8 @@ POST /exams/_search?size=0 } } ``` - +% TEST[setup:exams] +% TEST[s/size=0/size=0&filter_path=aggregations/] ## Missing value [_missing_value_6] @@ -81,6 +84,7 @@ POST /exams/_search?size=0 } } ``` +% TEST[setup:exams] 1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `10`. @@ -133,5 +137,5 @@ For each histogram field the `avg` aggregation adds each number in the `values` } } ``` - +% TESTRESPONSE[skip:test not setup] diff --git a/docs/reference/aggregations/search-aggregations-metrics-boxplot-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-boxplot-aggregation.md index 5966978a3bc2c..1588501909a30 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-boxplot-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-boxplot-aggregation.md @@ -22,6 +22,7 @@ A `boxplot` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE Let’s look at a boxplot representing load time: @@ -38,6 +39,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. The field `load_time` must be a numeric field @@ -61,6 +63,7 @@ The response will look like this: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] In this case, the lower and upper whisker values are equal to the min and max. In general, these values are the 1.5 * IQR range, which is to say the nearest values to `q1 - (1.5 * IQR)` and `q3 + (1.5 * IQR)`. Since this is an approximation, the given values may not actually be observed values from the data, but should be within a reasonable error bound of them. While the Boxplot aggregation doesn’t directly return outlier points, you can check if `lower > min` or `upper < max` to see if outliers exist on either side, and then query for them directly. @@ -91,7 +94,9 @@ GET latency/_search } } ``` - +% TEST[setup:latency] +% TEST[s/_search/_search?filter_path=aggregations/] +% TEST[s/"timeUnit": 1000/"timeUnit": 10/] ## Boxplot values are (usually) approximate [search-aggregations-metrics-boxplot-aggregation-approximation] @@ -122,6 +127,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Compression controls memory usage and approximation error @@ -151,6 +157,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Optimize TDigest for accuracy, at the expense of performance @@ -176,6 +183,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `10`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-cardinality-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-cardinality-aggregation.md index f99596a450ffd..9f99f639dfc09 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-cardinality-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-cardinality-aggregation.md @@ -23,6 +23,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -36,6 +37,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Precision control [_precision_control] @@ -54,6 +56,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. The `precision_threshold` options allows to trade memory for accuracy, and defines a unique count below which counts are expected to be close to accurate. Above this value, counts might become a bit more fuzzy. The maximum supported value is 40000, thresholds above this number will have the same effect as a threshold of 40000. The default value is `3000`. @@ -115,7 +118,8 @@ POST /sales/_search?size=0 } } ``` - +% TEST[setup:sales] +% TEST[s/size=0/size=0&filter_path=aggregations/] ## Missing value [_missing_value_8] @@ -134,6 +138,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] 1. Documents without a value in the `tag` field will fall into the same bucket as documents that have the value `N/A`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-cartesian-bounds-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-cartesian-bounds-aggregation.md index b3f55b5616016..566af3b7234aa 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-cartesian-bounds-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-cartesian-bounds-aggregation.md @@ -83,7 +83,7 @@ The response for the above aggregation: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## Cartesian Bounds Aggregation on `shape` fields [cartesian-bounds-aggregation-shape] @@ -120,6 +120,7 @@ POST /places/_search?size=0 } } ``` +% TEST ```console-result { @@ -140,4 +141,4 @@ POST /places/_search?size=0 } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] diff --git a/docs/reference/aggregations/search-aggregations-metrics-cartesian-centroid-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-cartesian-centroid-aggregation.md index aadb885f7138d..f642e01aaa9ee 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-cartesian-centroid-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-cartesian-centroid-aggregation.md @@ -70,6 +70,7 @@ The response for the above aggregation: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] The `cartesian_centroid` aggregation is more interesting when combined as a sub-aggregation to other bucket aggregations. @@ -90,6 +91,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] The above example uses `cartesian_centroid` as a sub-aggregation to a [terms](/reference/aggregations/search-aggregations-bucket-terms-aggregation.md) bucket aggregation for finding the central location for museums in each city. @@ -141,7 +143,7 @@ The response for the above aggregation: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## Cartesian Centroid Aggregation on `shape` fields [cartesian-centroid-aggregation-geo-shape] @@ -185,6 +187,7 @@ POST /places/_search?size=0 } } ``` +% TEST ```console-result { @@ -200,4 +203,4 @@ POST /places/_search?size=0 } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] diff --git a/docs/reference/aggregations/search-aggregations-metrics-extendedstats-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-extendedstats-aggregation.md index 99121d173581a..64f691e2f0104 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-extendedstats-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-extendedstats-aggregation.md @@ -22,6 +22,7 @@ GET /exams/_search } } ``` +% TEST[setup:exams] The above aggregation computes the grades statistics over all documents. The aggregation type is `extended_stats` and the `field` setting defines the numeric field of the documents the stats will be computed on. The above will return the following: @@ -57,6 +58,7 @@ The `std_deviation` and `variance` are calculated as population metrics so they } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The name of the aggregation (`grades_stats` above) also serves as the key by which the aggregation result can be retrieved from the returned response. @@ -78,6 +80,7 @@ GET /exams/_search } } ``` +% TEST[setup:exams] 1. `sigma` controls how many standard deviations +/- from the mean should be displayed @@ -121,7 +124,8 @@ GET /exams/_search } } ``` - +% TEST[setup:exams] +% TEST[s/_search/_search?filter_path=aggregations/] ## Missing value [_missing_value_9] @@ -141,6 +145,7 @@ GET /exams/_search } } ``` +% TEST[setup:exams] 1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `0`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-geo-line.md b/docs/reference/aggregations/search-aggregations-metrics-geo-line.md index 47904b3d5a699..c4aa09a16a96f 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-geo-line.md +++ b/docs/reference/aggregations/search-aggregations-metrics-geo-line.md @@ -72,6 +72,7 @@ Which returns: } } ``` +% TESTRESPONSE The resulting [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) contains both a `LineString` geometry for the path generated by the aggregation, as well as a map of `properties`. The property `complete` informs of whether all documents matched were used to generate the geometry. The [`size` option](#search-aggregations-metrics-geo-line-size) can be used to limit the number of documents included in the aggregation, leading to results with `complete: false`. Exactly which documents are dropped from results [depends on whether the aggregation is based on `time_series` or not](#search-aggregations-metrics-geo-line-grouping-time-series-advantages). @@ -93,6 +94,7 @@ Example usage configuring `my_location` as the point field: "field": "my_location" } ``` +% NOTCONSOLE `sort` : (Required outside [`time_series`](#search-aggregations-metrics-geo-line-grouping-time-series) aggregations) @@ -106,6 +108,7 @@ Example usage configuring `@timestamp` as the sort key: "field": "@timestamp" } ``` +% NOTCONSOLE `include_sort` : (Optional, boolean, default: `false`) This option includes, when true, an additional array of the sort values in the feature properties. @@ -205,6 +208,7 @@ POST /tour/_search?filter_path=aggregations } } ``` +% TEST[continued] Which returns: @@ -262,6 +266,7 @@ Which returns: } } ``` +% TESTRESPONSE These results contain an array of buckets, where each bucket is a JSON object with the `key` showing the name of the `city` field, and an inner aggregation result called `museum_tour` containing a [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) describing the actual route between the various attractions in that city. Each result also includes a `properties` object with a `complete` value which will be `false` if the geometry was truncated to the limits specified in the `size` parameter. Note that when we use `time_series` in the next example, we will get the same results structured a little differently. @@ -294,6 +299,7 @@ POST /tour/_search?filter_path=aggregations } } ``` +% TEST[continued] ::::{note} The `geo_line` aggregation no longer requires the `sort` field when nested within a [`time_series` aggregation](/reference/aggregations/search-aggregations-bucket-time-series-aggregation.md). This is because the sort field is set to `@timestamp`, which all time-series indexes are pre-sorted by. If you do set this parameter, and set it to something other than `@timestamp` you will get an error. @@ -360,6 +366,7 @@ This query will result in: } } ``` +% TESTRESPONSE These results are essentially the same as with the previous `terms` aggregation example, but structured differently. Here we see the buckets returned as a map, where the key is an internal description of the TSID. This TSID is unique for each unique combination of fields with `time_series_dimension: true`. Each bucket contains a `key` field which is also a map of all dimension values for the TSID, in this case only the city name is used for grouping. In addition, there is an inner aggregation result called `museum_tour` containing a [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) describing the actual route between the various attractions in that city. Each result also includes a `properties` object with a `complete` value which will be false if the geometry was simplified to the limits specified in the `size` parameter. diff --git a/docs/reference/aggregations/search-aggregations-metrics-geobounds-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-geobounds-aggregation.md index afb3558b66c5b..4f24c4a151271 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-geobounds-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-geobounds-aggregation.md @@ -80,7 +80,7 @@ The response for the above aggregation: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## Geo Bounds Aggregation on `geo_shape` fields [geobounds-aggregation-geo-shape] @@ -121,6 +121,7 @@ POST /places/_search?size=0 } } ``` +% TEST ```console-result { @@ -141,4 +142,4 @@ POST /places/_search?size=0 } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] diff --git a/docs/reference/aggregations/search-aggregations-metrics-geocentroid-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-geocentroid-aggregation.md index 4a9fa6d76d966..9683fc190b7bd 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-geocentroid-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-geocentroid-aggregation.md @@ -70,6 +70,7 @@ The response for the above aggregation: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] The `geo_centroid` aggregation is more interesting when combined as a sub-aggregation to other bucket aggregations. @@ -90,6 +91,7 @@ POST /museums/_search?size=0 } } ``` +% TEST[continued] The above example uses `geo_centroid` as a sub-aggregation to a [terms](/reference/aggregations/search-aggregations-bucket-terms-aggregation.md) bucket aggregation for finding the central location for museums in each city. @@ -141,7 +143,7 @@ The response for the above aggregation: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ## Geo Centroid Aggregation on `geo_shape` fields [geocentroid-aggregation-geo-shape] @@ -185,6 +187,7 @@ POST /places/_search?size=0 } } ``` +% TEST ```console-result { @@ -200,6 +203,7 @@ POST /places/_search?size=0 } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/] ::::{admonition} Using geo_centroid as a sub-aggregation of geohash_grid :class: warning diff --git a/docs/reference/aggregations/search-aggregations-metrics-max-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-max-aggregation.md index 9c2776976b973..e3498c9890daf 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-max-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-max-aggregation.md @@ -24,6 +24,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -37,6 +38,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] As can be seen, the name of the aggregation (`max_price` above) also serves as the key by which the aggregation result can be retrieved from the returned response. @@ -67,7 +69,8 @@ POST /sales/_search } } ``` - +% TEST[setup:sales] +% TEST[s/_search/_search?filter_path=aggregations/] ## Missing value [_missing_value_10] @@ -86,6 +89,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `10`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-median-absolute-deviation-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-median-absolute-deviation-aggregation.md index d39983fc31d34..c06c6667d9625 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-median-absolute-deviation-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-median-absolute-deviation-aggregation.md @@ -37,6 +37,7 @@ GET reviews/_search } } ``` +% TEST[setup:reviews] 1. `rating` must be a numeric field @@ -56,7 +57,7 @@ The resulting median absolute deviation of `2` tells us that there is a fair amo } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] ## Approximation [_approximation] @@ -78,6 +79,7 @@ GET reviews/_search } } ``` +% TEST[setup:reviews] The default `compression` value for this aggregation is `1000`. At this compression level this aggregation is usually within 5% of the exact result, but observed performance will depend on the sample data. @@ -115,6 +117,7 @@ GET reviews/_search?filter_path=aggregations } } ``` +% TEST[setup:reviews] Which will result in: @@ -152,5 +155,5 @@ GET reviews/_search } } ``` - +% TEST[setup:reviews] diff --git a/docs/reference/aggregations/search-aggregations-metrics-min-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-min-aggregation.md index 2c313a3d2dbef..fa606053ba581 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-min-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-min-aggregation.md @@ -24,6 +24,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -38,6 +39,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] 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. @@ -68,7 +70,8 @@ POST /sales/_search } } ``` - +% TEST[setup:sales] +% TEST[s/_search/_search?filter_path=aggregations/] ## Missing value [_missing_value_12] @@ -87,6 +90,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `10`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-percentile-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-percentile-aggregation.md index b45a126bda750..aa204d83ebb95 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-percentile-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-percentile-aggregation.md @@ -32,6 +32,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. The field `load_time` must be a numeric field @@ -57,6 +58,14 @@ By default, the `percentile` metric will generate a range of percentiles: `[ 1, } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/"1.0": 10.0/"1.0": 9.9/] +% TESTRESPONSE[s/"5.0": 30.0/"5.0": 29.5/] +% TESTRESPONSE[s/"25.0": 170.0/"25.0": 167.5/] +% TESTRESPONSE[s/"50.0": 445.0/"50.0": 445.0/] +% TESTRESPONSE[s/"75.0": 720.0/"75.0": 722.5/] +% TESTRESPONSE[s/"95.0": 940.0/"95.0": 940.5/] +% TESTRESPONSE[s/"99.0": 980.0/"99.0": 980.1/] As you can see, the aggregation will return a calculated value for each percentile in the default range. If we assume response times are in milliseconds, it is immediately obvious that the webpage normally loads in 10-720ms, but occasionally spikes to 940-980ms. @@ -76,6 +85,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Use the `percents` parameter to specify particular percentiles to calculate @@ -98,6 +108,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] Response: @@ -141,7 +152,14 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/"value": 10.0/"value": 9.9/] +% TESTRESPONSE[s/"value": 30.0/"value": 29.5/] +% TESTRESPONSE[s/"value": 170.0/"value": 167.5/] +% TESTRESPONSE[s/"value": 445.0/"value": 445.0/] +% TESTRESPONSE[s/"value": 720.0/"value": 722.5/] +% TESTRESPONSE[s/"value": 940.0/"value": 940.5/] +% TESTRESPONSE[s/"value": 980.0/"value": 980.1/] ## Script [_script_10] @@ -171,7 +189,9 @@ GET latency/_search } } ``` - +% TEST[setup:latency] +% TEST[s/_search/_search?filter_path=aggregations/] +% TEST[s/"timeUnit": 1000/"timeUnit": 10/] ## Percentiles are (usually) approximate [search-aggregations-metrics-percentile-aggregation-approximation] @@ -218,6 +238,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Compression controls memory usage and approximation error @@ -249,6 +270,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Optimize TDigest for accuracy, at the expense of performance @@ -279,6 +301,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. `hdr` object indicates that HDR Histogram should be used to calculate the percentiles and specific settings for this algorithm can be specified inside the object 2. `number_of_significant_value_digits` specifies the resolution of values for the histogram in number of significant digits @@ -305,6 +328,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `10`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-percentile-rank-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-percentile-rank-aggregation.md index 678cd089706af..7e729f557cb1b 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-percentile-rank-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-percentile-rank-aggregation.md @@ -35,6 +35,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. The field `load_time` must be a numeric field @@ -55,6 +56,9 @@ The response will look like this: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/"500.0": 55.0/"500.0": 55.00000000000001/] +% TESTRESPONSE[s/"600.0": 64.0/"600.0": 64.0/] From this information you can determine you are hitting the 99% load time target but not quite hitting the 95% load time target @@ -77,6 +81,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] Response: @@ -100,7 +105,9 @@ Response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/"value": 55.0/"value": 55.00000000000001/] +% TESTRESPONSE[s/"value": 64.0/"value": 64.0/] ## Script [_script_9] @@ -131,7 +138,8 @@ GET latency/_search } } ``` - +% TEST[setup:latency] +% TEST[s/_search/_search?filter_path=aggregations/] ## HDR Histogram [_hdr_histogram] @@ -156,6 +164,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. `hdr` object indicates that HDR Histogram should be used to calculate the percentiles and specific settings for this algorithm can be specified inside the object 2. `number_of_significant_value_digits` specifies the resolution of values for the histogram in number of significant digits @@ -183,6 +192,7 @@ GET latency/_search } } ``` +% TEST[setup:latency] 1. Documents without a value in the `load_time` field will fall into the same bucket as documents that have the value `10`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-rate-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-rate-aggregation.md index be3c46af84d65..5c54ab48052b1 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-rate-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-rate-aggregation.md @@ -26,6 +26,7 @@ A `rate` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE The following request will group all sales records into monthly buckets and then convert the number of sales transactions in each bucket into per annual sales rate. @@ -50,6 +51,7 @@ GET sales/_search } } ``` +% TEST[setup:sales] 1. Histogram is grouped by month. 2. But the rate is converted into annual rate. @@ -92,6 +94,7 @@ The response will return the annual rate of transactions in each bucket. Since t } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] Instead of counting the number of documents, it is also possible to calculate a sum of all values of the fields in the documents in each bucket or the number of values in each bucket. The following request will group all sales records into monthly bucket and than calculate the total monthly sales and convert them into average daily sales. @@ -117,6 +120,7 @@ GET sales/_search } } ``` +% TEST[setup:sales] 1. Histogram is grouped by month. 2. Calculate sum of all sale prices @@ -160,6 +164,7 @@ The response will contain the average daily sale prices for each month. } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] You can also take advantage of `composite` aggregations to calculate the average daily sale price for each item in your inventory @@ -199,6 +204,7 @@ GET sales/_search?filter_path=aggregations&size=0 } } ``` +% TEST[setup:sales] 1. Composite aggregation with a date histogram source and a source for the item type. 2. The date histogram source grouping monthly @@ -319,6 +325,7 @@ GET sales/_search } } ``` +% TEST[setup:sales] 1. Histogram is grouped by month. 2. Calculate number of all sale prices @@ -363,6 +370,7 @@ The response will contain the average daily sale prices for each month. } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] By default `sum` mode is used. @@ -440,6 +448,7 @@ GET sales/_search } } ``` +% TEST[setup:sales] ```console-result { @@ -476,5 +485,5 @@ GET sales/_search } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] diff --git a/docs/reference/aggregations/search-aggregations-metrics-scripted-metric-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-scripted-metric-aggregation.md index 9defeda72a325..0a20a62b576fe 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-scripted-metric-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-scripted-metric-aggregation.md @@ -39,6 +39,7 @@ POST ledger/_search?size=0 } } ``` +% TEST[setup:ledger] 1. `init_script` is an optional parameter, all other scripts are required. @@ -58,6 +59,8 @@ The response for the above aggregation: } } ``` +% TESTRESPONSE[s/"took": 218/"took": $body.took/] +% TESTRESPONSE[s/\.\.\./"_shards": $body._shards, "hits": $body.hits, "timed_out": false,/] The above example can also be specified using stored scripts as follows: @@ -87,6 +90,7 @@ POST ledger/_search?size=0 } } ``` +% TEST[setup:ledger,stored_scripted_metric_script] 1. script parameters for `init`, `map` and `combine` scripts must be specified in a global `params` object so that it can be shared between the scripts. @@ -157,7 +161,7 @@ Lets say that documents 1 and 3 end up on shard A and documents 2 and 4 end up o ```js "state" : {} ``` - +% NOTCONSOLE ### After init_script [_after_init_script] @@ -222,6 +226,7 @@ The reduce_script receives a `states` array containing the result of the combine 120 ] ``` +% NOTCONSOLE It reduces the responses for the shards down to a final overall profit figure (by summing the values) and returns this as the result of the aggregation to produce the response: @@ -236,8 +241,7 @@ It reduces the responses for the shards down to a final overall profit figure (b } } ``` - - +% NOTCONSOLE ## Other parameters [scripted-metric-aggregation-parameters] @@ -247,7 +251,7 @@ params ```js "params" : {} ``` - + % NOTCONSOLE ## Empty buckets [scripted-metric-aggregation-empty-buckets] diff --git a/docs/reference/aggregations/search-aggregations-metrics-stats-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-stats-aggregation.md index 1fe99e261d240..ff8b58cf3f055 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-stats-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-stats-aggregation.md @@ -21,6 +21,7 @@ POST /exams/_search?size=0 } } ``` +% TEST[setup:exams] The above aggregation computes the grades statistics over all documents. The aggregation type is `stats` and the `field` setting defines the numeric field of the documents the stats will be computed on. The above will return the following: @@ -39,6 +40,7 @@ The above aggregation computes the grades statistics over all documents. The agg } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The name of the aggregation (`grades_stats` above) also serves as the key by which the aggregation result can be retrieved from the returned response. @@ -67,7 +69,8 @@ POST /exams/_search } } ``` - +% TEST[setup:exams] +% TEST[s/_search/_search?filter_path=aggregations/] ## Missing value [_missing_value_15] @@ -86,6 +89,7 @@ POST /exams/_search?size=0 } } ``` +% TEST[setup:exams] 1. Documents without a value in the `grade` field will fall into the same bucket as documents that have the value `0`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-string-stats-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-string-stats-aggregation.md index 04d37af374c00..8aaa44ab1df39 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-string-stats-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-string-stats-aggregation.md @@ -27,6 +27,7 @@ POST /my-index-000001/_search?size=0 } } ``` +% TEST[setup:messages] The above aggregation computes the string statistics for the `message` field in all documents. The aggregation type is `string_stats` and the `field` parameter defines the field of the documents the stats will be computed on. The above will return the following: @@ -45,6 +46,7 @@ The above aggregation computes the string statistics for the `message` field in } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The name of the aggregation (`message_stats` above) also serves as the key by which the aggregation result can be retrieved from the returned response. @@ -65,6 +67,7 @@ POST /my-index-000001/_search?size=0 } } ``` +% TEST[setup:messages] 1. Set the `show_distribution` parameter to `true`, so that probability distribution for all characters is returned in the results. @@ -109,6 +112,7 @@ POST /my-index-000001/_search?size=0 } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The `distribution` object shows the probability of each character appearing in all terms. The characters are sorted by descending probability. @@ -136,7 +140,8 @@ POST /my-index-000001/_search } } ``` - +% TEST[setup:messages] +% TEST[s/_search/_search?filter_path=aggregations/] ## Missing value [_missing_value_16] @@ -155,6 +160,7 @@ POST /my-index-000001/_search?size=0 } } ``` +% TEST[setup:messages] 1. Documents without a value in the `message` field will be treated as documents that have the value `[empty message]`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-sum-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-sum-aggregation.md index cf97a4697b330..bc96de789c8a3 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-sum-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-sum-aggregation.md @@ -26,6 +26,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Resulting in: @@ -39,6 +40,7 @@ Resulting in: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The name of the aggregation (`hat_prices` above) also serves as the key by which the aggregation result can be retrieved from the returned response. @@ -77,7 +79,8 @@ POST /sales/_search?size=0 } } ``` - +% TEST[setup:sales] +% TEST[s/size=0/size=0&filter_path=aggregations/] ## Missing value [_missing_value_17] @@ -103,7 +106,7 @@ POST /sales/_search?size=0 } } ``` - +% TEST[setup:sales] ## Histogram fields [search-aggregations-metrics-sum-aggregation-histogram-fields] diff --git a/docs/reference/aggregations/search-aggregations-metrics-top-hits-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-top-hits-aggregation.md index 741ffd3fdae7c..7559f17a0628b 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-top-hits-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-top-hits-aggregation.md @@ -80,6 +80,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Possible response: @@ -177,7 +178,10 @@ Possible response: } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] +% TESTRESPONSE[s/AVnNBmauCQpcRyxw6ChK/$body.aggregations.top_tags.buckets.0.top_sales_hits.hits.hits.0._id/] +% TESTRESPONSE[s/AVnNBmauCQpcRyxw6ChL/$body.aggregations.top_tags.buckets.1.top_sales_hits.hits.hits.0._id/] +% TESTRESPONSE[s/AVnNBmatCQpcRyxw6ChH/$body.aggregations.top_tags.buckets.2.top_sales_hits.hits.hits.0._id/] ## Field collapse example [_field_collapse_example] @@ -219,6 +223,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] At the moment the `max` (or `min`) aggregator is needed to make sure the buckets from the `terms` aggregator are ordered according to the score of the most relevant webpage per domain. Unfortunately the `top_hits` aggregator can’t be used in the `order` option of the `terms` aggregator yet. @@ -265,6 +270,7 @@ PUT /sales/_doc/1?refresh ] } ``` +% TEST[continued] It’s now possible to execute the following `top_hits` aggregation (wrapped in a `nested` aggregation): @@ -296,6 +302,8 @@ POST /sales/_search } } ``` +% TEST[continued] +% TEST[s/_search/_search\?filter_path=aggregations.by_sale.by_user.buckets/] Top hits response snippet with a nested hit, which resides in the first slot of array field `comments`: @@ -341,6 +349,7 @@ Top hits response snippet with a nested hit, which resides in the first slot of } } ``` +% TESTRESPONSE[s/\.\.\.//] 1. Name of the array field containing the nested hit 2. Position if the nested hit in the containing array @@ -385,7 +394,7 @@ In the example below a nested hit resides in the first slot of the field `nested } ... ``` - +% NOTCONSOLE ## Use in pipeline aggregations [_use_in_pipeline_aggregations] @@ -429,6 +438,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] The `bucket_path` uses the `top_hits` name `top_sales_hits` and a keyword for the field providing the aggregate value, namely `_source` field `price` in the example above. Other options include `top_sales_hits[_sort]`, for filtering on the sort value `date` above, and `top_sales_hits[_score]`, for filtering on the score of the top hit. diff --git a/docs/reference/aggregations/search-aggregations-metrics-top-metrics.md b/docs/reference/aggregations/search-aggregations-metrics-top-metrics.md index 1a93b8870cb33..4222428d1ae0b 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-top-metrics.md +++ b/docs/reference/aggregations/search-aggregations-metrics-top-metrics.md @@ -43,6 +43,7 @@ Which returns: } } ``` +% TESTRESPONSE `top_metrics` is fairly similar to [`top_hits`](/reference/aggregations/search-aggregations-metrics-top-hits-aggregation.md) in spirit but because it is more limited it is able to do its job using less memory and is often faster. @@ -138,7 +139,7 @@ Which returns: } } ``` - +% TESTRESPONSE ## `missing` [_missing] @@ -248,6 +249,7 @@ Which returns: } } ``` +% TESTRESPONSE The default `size` is 1. The maximum default size is `10` because the aggregation’s working storage is "dense", meaning we allocate `size` slots for every bucket. `10` is a **very** conservative default maximum and you can raise it if you need to by changing the `top_metrics_max_size` index setting. But know that large sizes can take a fair bit of memory, especially if they are inside of an aggregation which makes many buckes like a large [terms aggregation](#search-aggregations-metrics-top-metrics-example-terms). If you till want to raise it, use something like: @@ -257,6 +259,7 @@ PUT /test/_settings "top_metrics_max_size": 100 } ``` +% TEST[continued] ::::{note} If `size` is more than `1` the `top_metrics` aggregation can’t be the **target** of a sort. @@ -337,6 +340,7 @@ Which returns: } } ``` +% TESTRESPONSE Unlike `top_hits`, you can sort buckets by the results of this metric: @@ -361,6 +365,7 @@ POST /node/_search?filter_path=aggregations } } ``` +% TEST[continued] Which returns: @@ -390,7 +395,7 @@ Which returns: } } ``` - +% TESTRESPONSE ### Mixed sort types [_mixed_sort_types] @@ -430,6 +435,7 @@ Which returns: } } ``` +% TESTRESPONSE While this is better than an error it **probably** isn’t what you were going for. While it does lose some precision, you can explicitly cast the whole number fields to floating points with something like: @@ -446,6 +452,7 @@ POST /test*/_search?filter_path=aggregations } } ``` +% TEST[continued] Which returns the much more expected: @@ -458,7 +465,7 @@ Which returns the much more expected: } } ``` - +% TESTRESPONSE ### Use in pipeline aggregations [_use_in_pipeline_aggregations_2] @@ -493,6 +500,7 @@ POST /test*/_search?filter_path=aggregations } } ``` +% TEST[continued] The `bucket_path` uses the `top_metrics` name `tm` and a keyword for the metric providing the aggregate value, namely `m`. diff --git a/docs/reference/aggregations/search-aggregations-metrics-ttest-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-ttest-aggregation.md index 95970a6a3584f..8b8a78dd9ae20 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-ttest-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-ttest-aggregation.md @@ -22,6 +22,7 @@ A `t_test` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE Assuming that we have a record of node start up times before and after upgrade, let’s look at a t-test to see if upgrade affected the node start up time in a meaningful way. @@ -40,6 +41,7 @@ GET node_upgrade/_search } } ``` +% TEST[setup:node_upgrade] 1. The field `startup_time_before` must be a numeric field. 2. The field `startup_time_after` must be a numeric field. @@ -59,6 +61,7 @@ The response will return the p-value or probability value for the test. It is th } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] 1. The p-value. @@ -111,6 +114,7 @@ GET node_upgrade/_search } } ``` +% TEST[setup:node_upgrade] 1. The field `startup_time_before` must be a numeric field. 2. Any query that separates two groups can be used here. @@ -130,6 +134,7 @@ GET node_upgrade/_search } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] 1. The p-value. @@ -171,5 +176,6 @@ GET node_upgrade/_search } } ``` - +% TEST[setup:node_upgrade] +% TEST[s/_search/_search?filter_path=aggregations/] diff --git a/docs/reference/aggregations/search-aggregations-metrics-valuecount-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-valuecount-aggregation.md index 318d131006299..d0a60c47f1489 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-valuecount-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-valuecount-aggregation.md @@ -19,6 +19,7 @@ POST /sales/_search?size=0 } } ``` +% TEST[setup:sales] Response: @@ -32,6 +33,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The name of the aggregation (`types_count` above) also serves as the key by which the aggregation result can be retrieved from the returned response. @@ -63,7 +65,8 @@ POST /sales/_search } } ``` - +% TEST[setup:sales] +% TEST[s/_search/_search?filter_path=aggregations/] ## Histogram fields [search-aggregations-metrics-valuecount-aggregation-histogram-fields] @@ -114,5 +117,5 @@ Eventually, the aggregation will add all values for all histograms and return th } } ``` - +% TESTRESPONSE[skip:test not setup] diff --git a/docs/reference/aggregations/search-aggregations-metrics-weight-avg-aggregation.md b/docs/reference/aggregations/search-aggregations-metrics-weight-avg-aggregation.md index 6829795ae7bca..4ac71a49aa83e 100644 --- a/docs/reference/aggregations/search-aggregations-metrics-weight-avg-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-metrics-weight-avg-aggregation.md @@ -61,6 +61,7 @@ POST /exams/_search } } ``` +% TEST[setup:exams] Which yields a response like: @@ -74,6 +75,7 @@ Which yields a response like: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] While multiple values-per-field are allowed, only one weight is allowed. If the aggregation encounters a document that has more than one weight (e.g. the weight field is a multi-valued field) it will abort the search. If you have this situation, you should build a [Runtime field](#search-aggregations-metrics-weight-avg-aggregation-runtime-field) to combine those values into a single weight. @@ -105,6 +107,7 @@ POST /exams/_search } } ``` +% TEST The three values (`1`, `2`, and `3`) will be included as independent values, all with the weight of `2`: @@ -118,6 +121,7 @@ The three values (`1`, `2`, and `3`) will be included as independent values, all } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] The aggregation returns `2.0` as the result, which matches what we would expect when calculating by hand: `((1*2) + (2*2) + (3*2)) / (2+2+2) == 2` @@ -205,5 +209,5 @@ POST /exams/_search } } ``` - +% TEST[setup:exams] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-avg-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-avg-bucket-aggregation.md index 16dae6d842c58..c9a5e073e17ab 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-avg-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-avg-bucket-aggregation.md @@ -18,7 +18,7 @@ A sibling pipeline aggregation which calculates the mean value of a specified me "format": "#,##0.00;(#,##0.00)" } ``` - +% NOTCONSOLE ## Parameters [avg-bucket-params] @@ -75,6 +75,7 @@ POST _search } } ``` +% TEST[setup:sales] 1. Start of the `avg_bucket` configuration. Comment is not part of the example. 2. End of the `avg_bucket` configuration. Comment is not part of the example. @@ -124,5 +125,7 @@ The request returns the following response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-bucket-script-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-bucket-script-aggregation.md index f8330a2966eb3..e30c705a47bb8 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-bucket-script-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-bucket-script-aggregation.md @@ -24,6 +24,7 @@ A `bucket_script` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE 1. Here, `my_var1` is the name of the variable for this buckets path to use in the script, `the_sum` is the path to the metrics to use for that variable. @@ -83,6 +84,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] And the following may be the response: @@ -151,5 +153,7 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-bucket-selector-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-bucket-selector-aggregation.md index 6d957f9da6461..ec3726ab3685b 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-bucket-selector-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-bucket-selector-aggregation.md @@ -29,6 +29,7 @@ A `bucket_selector` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE 1. Here, `my_var1` is the name of the variable for this buckets path to use in the script, `the_sum` is the path to the metrics to use for that variable. @@ -72,6 +73,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] And the following may be the response: @@ -105,6 +107,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] 1. Bucket for `2015/02/01 00:00:00` has been removed as its total sales was less than 200 diff --git a/docs/reference/aggregations/search-aggregations-pipeline-bucket-sort-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-bucket-sort-aggregation.md index bf0efecbd633f..70e6e83e73241 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-bucket-sort-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-bucket-sort-aggregation.md @@ -31,6 +31,7 @@ A `bucket_sort` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE 1. Here, `sort_field_1` is the bucket path to the variable to be used as the primary sort and its order is ascending. @@ -75,6 +76,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `sort` is set to use the values of `total_sales` in descending order 2. `size` is set to `3` meaning only the top 3 months in `total_sales` will be returned @@ -120,7 +122,9 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 82/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] ## Truncating without sorting [_truncating_without_sorting] @@ -150,6 +154,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] Response: @@ -172,5 +177,7 @@ Response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-cumulative-cardinality-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-cumulative-cardinality-aggregation.md index 9da1d086b9561..7c6a4b5bd4ac7 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-cumulative-cardinality-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-cumulative-cardinality-aggregation.md @@ -22,6 +22,7 @@ A `cumulative_cardinality` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$cumulative-cardinality-params$$$ @@ -58,6 +59,7 @@ GET /user_hits/_search } } ``` +% TEST[setup:user_hits] 1. `buckets_path` instructs this aggregation to use the output of the `distinct_users` aggregation for the cumulative cardinality @@ -111,6 +113,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] Note how the second day, `2019-01-02`, has two distinct users but the `total_new_users` metric generated by the cumulative pipeline agg only increments to three. This means that only one of the two users that day were new, the other had already been seen in the previous day. This happens again on the third day, where only one of three users is completely new. @@ -152,6 +157,7 @@ GET /user_hits/_search } } ``` +% TEST[setup:user_hits] And the following may be the response: @@ -208,5 +214,7 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-cumulative-sum-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-cumulative-sum-aggregation.md index 8b977ec824fff..191fea50a1c1b 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-cumulative-sum-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-cumulative-sum-aggregation.md @@ -20,6 +20,7 @@ A `cumulative_sum` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$cumulative-sum-params$$$ @@ -56,6 +57,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this cumulative sum aggregation to use the output of the `sales` aggregation for the cumulative sum @@ -109,5 +111,7 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-derivative-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-derivative-aggregation.md index f6151aecdfbb1..2a056ae1f16b9 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-derivative-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-derivative-aggregation.md @@ -18,6 +18,7 @@ A `derivative` aggregation looks like this in isolation: "buckets_path": "the_sum" } ``` +% NOTCONSOLE $$$derivative-params$$$ @@ -58,6 +59,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this derivative aggregation to use the output of the `sales` aggregation for the derivative @@ -108,6 +110,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] 1. No derivative for the first bucket since we need at least 2 data points to calculate the derivative 2. Derivative value units are implicitly defined by the `sales` aggregation and the parent histogram so in this case the units would be $/month assuming the `price` field has units of $. @@ -150,6 +155,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` for the second derivative points to the name of the first derivative @@ -203,6 +209,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 50/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] 1. No second derivative for the first two buckets since we need at least 2 data points from the first derivative to calculate the second derivative @@ -239,6 +248,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `unit` specifies what unit to use for the x-axis of the derivative calculation @@ -291,6 +301,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 50/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] 1. `value` is reported in the original units of *per month* 2. `normalized_value` is reported in the desired units of *per day* diff --git a/docs/reference/aggregations/search-aggregations-pipeline-extended-stats-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-extended-stats-bucket-aggregation.md index 40e7569eafe6b..5ff391edd66f5 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-extended-stats-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-extended-stats-bucket-aggregation.md @@ -22,6 +22,7 @@ A `extended_stats_bucket` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$extended-stats-bucket-params$$$ @@ -60,6 +61,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 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. @@ -126,5 +128,7 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-inference-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-inference-bucket-aggregation.md index 529e2389b8f20..9b727d1d692a1 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-inference-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-inference-bucket-aggregation.md @@ -31,6 +31,7 @@ A `inference` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE 1. The unique identifier or alias for the trained model. 2. The optional inference config which overrides the model’s default settings @@ -157,6 +158,7 @@ GET kibana_sample_data_logs/_search } } ``` +% TEST[skip:setup kibana sample data] 1. A composite bucket aggregation that aggregates the data by `client_ip`. 2. A series of metrics and bucket sub-aggregations. diff --git a/docs/reference/aggregations/search-aggregations-pipeline-max-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-max-bucket-aggregation.md index 169bb788dfba1..35f0654544c2f 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-max-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-max-bucket-aggregation.md @@ -20,6 +20,7 @@ A `max_bucket` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$max-bucket-params$$$ @@ -57,6 +58,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this max_bucket aggregation that we want the maximum value of the `sales` aggregation in the `sales_per_month` date histogram. @@ -105,6 +107,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] 1. `keys` is an array of strings since the maximum value may be present in multiple buckets diff --git a/docs/reference/aggregations/search-aggregations-pipeline-min-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-min-bucket-aggregation.md index bbee0c672507d..41b15c1bc8a37 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-min-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-min-bucket-aggregation.md @@ -20,6 +20,7 @@ A `min_bucket` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$min-bucket-params$$$ @@ -57,6 +58,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this min_bucket aggregation that we want the minimum value of the `sales` aggregation in the `sales_per_month` date histogram. @@ -105,6 +107,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] 1. `keys` is an array of strings since the minimum value may be present in multiple buckets diff --git a/docs/reference/aggregations/search-aggregations-pipeline-movfn-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-movfn-aggregation.md index af396d32b63aa..ee86ce05a0770 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-movfn-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-movfn-aggregation.md @@ -22,6 +22,7 @@ A `moving_fn` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$moving-fn-params$$$ @@ -61,6 +62,7 @@ POST /_search } } ``` +% TEST[setup:sales] 1. A `date_histogram` named "my_date_histo" is constructed on the "timestamp" field, with one-month intervals 2. A `sum` metric is used to calculate the sum of a field. This could be any numeric metric (sum, min, max, etc) @@ -118,7 +120,9 @@ An example response from the above aggregation may look like: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] ## Custom user scripting [_custom_user_scripting] @@ -152,6 +156,7 @@ POST /_search } } ``` +% TEST[setup:sales] ## shift parameter [shift-parameter] @@ -217,7 +222,7 @@ POST /_search } } ``` - +% TEST[setup:sales] ### min Function [_min_function] @@ -255,7 +260,7 @@ POST /_search } } ``` - +% TEST[setup:sales] ### sum Function [_sum_function] @@ -293,7 +298,7 @@ POST /_search } } ``` - +% TEST[setup:sales] ### stdDev Function [_stddev_function] @@ -332,6 +337,7 @@ POST /_search } } ``` +% TEST[setup:sales] The `avg` parameter must be provided to the standard deviation function because different styles of averages can be computed on the window (simple, linearly weighted, etc). The various moving averages that are detailed below can be used to calculate the average for the standard deviation function. @@ -374,7 +380,7 @@ POST /_search } } ``` - +% TEST[setup:sales] ## linearWeightedAvg Function [_linearweightedavg_function] @@ -415,7 +421,7 @@ POST /_search } } ``` - +% TEST[setup:sales] ## ewma Function [_ewma_function] @@ -456,7 +462,7 @@ POST /_search } } ``` - +% TEST[setup:sales] ## holt Function [_holt_function] @@ -502,6 +508,7 @@ POST /_search } } ``` +% TEST[setup:sales] In practice, the `alpha` value behaves very similarly in `holtMovAvg` as `ewmaMovAvg`: small values produce more smoothing and more lag, while larger values produce closer tracking and less lag. The value of `beta` is often difficult to see. Small values emphasize long-term trends (such as a constant linear trend in the whole series), while larger values emphasize short-term trends. @@ -553,6 +560,7 @@ POST /_search } } ``` +% TEST[setup:sales] ::::{warning} Multiplicative Holt-Winters works by dividing each data point by the seasonal value. This is problematic if any of your data is zero, or if there are gaps in the data (since this results in a divid-by-zero). To combat this, the `mult` Holt-Winters pads all values by a very small amount (1*10-10) so that all values are non-zero. This affects the result, but only minimally. If your data is non-zero, or you prefer to see `NaN` when zero’s are encountered, you can disable this behavior with `pad: false` diff --git a/docs/reference/aggregations/search-aggregations-pipeline-moving-percentiles-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-moving-percentiles-aggregation.md index 52e10e10db591..6627bf23fe723 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-moving-percentiles-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-moving-percentiles-aggregation.md @@ -23,6 +23,7 @@ A `moving_percentiles` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$moving-percentiles-params$$$ @@ -62,6 +63,7 @@ POST /_search } } ``` +% TEST[setup:sales] 1. A `date_histogram` named "my_date_histo" is constructed on the "timestamp" field, with one-day intervals 2. A `percentile` metric is used to calculate the percentiles of a field. @@ -131,6 +133,9 @@ And the following may be the response: } } ``` +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] The output format of the `moving_percentiles` aggregation is inherited from the format of the referenced [`percentiles`](/reference/aggregations/search-aggregations-metrics-percentile-aggregation.md) aggregation. diff --git a/docs/reference/aggregations/search-aggregations-pipeline-normalize-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-normalize-aggregation.md index e275570d7b74a..1929cf105976d 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-normalize-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-normalize-aggregation.md @@ -21,6 +21,7 @@ A `normalize` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$normalize_pipeline-params$$$ @@ -135,6 +136,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this normalize aggregation to use the output of the `sales` aggregation for rescaling 2. `method` sets which rescaling to apply. In this case, `percent_of_sum` will calculate the sales value as a percent of all sales in the parent bucket @@ -193,5 +195,7 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-percentiles-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-percentiles-bucket-aggregation.md index 7f3ea673505aa..586c65e937a5a 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-percentiles-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-percentiles-bucket-aggregation.md @@ -20,6 +20,7 @@ A `percentiles_bucket` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$percentiles-bucket-params$$$ @@ -60,6 +61,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this percentiles_bucket aggregation that we want to calculate percentiles for the `sales` aggregation in the `sales_per_month` date histogram. 2. `percents` specifies which percentiles we wish to calculate, in this case, the 25th, 50th and 75th percentiles. @@ -112,7 +114,9 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] ## Percentiles_bucket implementation [_percentiles_bucket_implementation] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-serialdiff-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-serialdiff-aggregation.md index ae5de13e69ace..b9d9f65d7211c 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-serialdiff-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-serialdiff-aggregation.md @@ -43,6 +43,7 @@ A `serial_diff` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$serial-diff-params$$$ diff --git a/docs/reference/aggregations/search-aggregations-pipeline-stats-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-stats-bucket-aggregation.md index b83d160aa185c..1f6fe70032827 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-stats-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-stats-bucket-aggregation.md @@ -20,6 +20,7 @@ A `stats_bucket` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$stats-bucket-params$$$ @@ -57,6 +58,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `bucket_paths` instructs this `stats_bucket` aggregation that we want the calculate stats for the `sales` aggregation in the `sales_per_month` date histogram. @@ -108,5 +110,7 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-pipeline-sum-bucket-aggregation.md b/docs/reference/aggregations/search-aggregations-pipeline-sum-bucket-aggregation.md index 47b3e32a2eb2f..2655d3c648169 100644 --- a/docs/reference/aggregations/search-aggregations-pipeline-sum-bucket-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-pipeline-sum-bucket-aggregation.md @@ -20,6 +20,7 @@ A `sum_bucket` aggregation looks like this in isolation: } } ``` +% NOTCONSOLE $$$sum-bucket-params$$$ @@ -57,6 +58,7 @@ POST /sales/_search } } ``` +% TEST[setup:sales] 1. `buckets_path` instructs this sum_bucket aggregation that we want the sum of the `sales` aggregation in the `sales_per_month` date histogram. @@ -104,5 +106,7 @@ And the following may be the response: } } ``` - +% TESTRESPONSE[s/"took": 11/"took": $body.took/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] diff --git a/docs/reference/aggregations/search-aggregations-random-sampler-aggregation.md b/docs/reference/aggregations/search-aggregations-random-sampler-aggregation.md index 96c0826b95e79..4661c65f93db4 100644 --- a/docs/reference/aggregations/search-aggregations-random-sampler-aggregation.md +++ b/docs/reference/aggregations/search-aggregations-random-sampler-aggregation.md @@ -40,6 +40,7 @@ GET kibana_sample_data_ecommerce/_search?size=0&track_total_hits=false } } ``` +% TEST[setup:kibana_sample_data_ecommerce] ## Top-level parameters for random_sampler [random-sampler-top-level-params] diff --git a/docs/reference/elasticsearch-plugins/mapper-annotated-text-usage.md b/docs/reference/elasticsearch-plugins/mapper-annotated-text-usage.md index 0170998d9a3cf..7245dc9ae957c 100644 --- a/docs/reference/elasticsearch-plugins/mapper-annotated-text-usage.md +++ b/docs/reference/elasticsearch-plugins/mapper-annotated-text-usage.md @@ -31,6 +31,7 @@ GET my-index-000001/_analyze "text":"Investors in [Apple](Apple+Inc.) rejoiced." } ``` +% NOTCONSOLE Response: @@ -75,6 +76,7 @@ Response: ] } ``` +% NOTCONSOLE 1. Note the whole annotation token `Apple Inc.` is placed, unchanged as a single token in the token stream and at the same position (position 2) as the text token (`apple`) it annotates. @@ -159,6 +161,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -170,6 +173,7 @@ Will become: ] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] ::::{note} Reordering text fields can have an effect on [phrase](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) and [span](/reference/query-languages/query-dsl/span-queries.md) queries. See the discussion about [`position_increment_gap`](/reference/elasticsearch/mapping-reference/position-increment-gap.md) for more detail. You can avoid this by making sure the `slop` parameter on the phrase queries is lower than the `position_increment_gap`. This is the default. @@ -207,6 +211,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -219,5 +224,5 @@ Will become: ] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch-plugins/repository-hdfs-config.md b/docs/reference/elasticsearch-plugins/repository-hdfs-config.md index 790feb2820f3a..96af2bd490f2e 100644 --- a/docs/reference/elasticsearch-plugins/repository-hdfs-config.md +++ b/docs/reference/elasticsearch-plugins/repository-hdfs-config.md @@ -18,6 +18,7 @@ PUT _snapshot/my_hdfs_repository } } ``` +% TEST[skip:we don't have hdfs set up while testing this] The following settings are supported: diff --git a/docs/reference/elasticsearch-plugins/repository-hdfs-security.md b/docs/reference/elasticsearch-plugins/repository-hdfs-security.md index f7b24e79ad95a..fcc4b110fcbf6 100644 --- a/docs/reference/elasticsearch-plugins/repository-hdfs-security.md +++ b/docs/reference/elasticsearch-plugins/repository-hdfs-security.md @@ -55,6 +55,7 @@ PUT _snapshot/my_hdfs_repository } } ``` +% TEST[skip:we don't have hdfs set up while testing this] If you are using different service principals for each node, you can use the `_HOST` pattern in your principal name. Elasticsearch will automatically replace the pattern with the hostname of the node at runtime: @@ -69,7 +70,7 @@ PUT _snapshot/my_hdfs_repository } } ``` - +% TEST[skip:we don't have hdfs set up while testing this] ## Authorization [repository-hdfs-security-authorization] diff --git a/docs/reference/elasticsearch/command-line-tools/service-tokens-command.md b/docs/reference/elasticsearch/command-line-tools/service-tokens-command.md index e6b5d7a9198cd..97abf8dd8b838 100644 --- a/docs/reference/elasticsearch/command-line-tools/service-tokens-command.md +++ b/docs/reference/elasticsearch/command-line-tools/service-tokens-command.md @@ -107,6 +107,7 @@ Use this bearer token to authenticate with your {{es}} cluster. ```shell curl -H "Authorization: Bearer AAEAAWVsYXN0aWM...vZmxlZXQtc2VydmVyL3Rva2VuMTo3TFdaSDZ" http://localhost:9200/_cluster/health ``` +% NOTCONSOLE ::::{note} If your node has `xpack.security.http.ssl.enabled` set to `true`, then you must specify `https` in the request URL. diff --git a/docs/reference/elasticsearch/elasticsearch-audit-events.md b/docs/reference/elasticsearch/elasticsearch-audit-events.md index d50c95982a3a8..745a7b9935bd4 100644 --- a/docs/reference/elasticsearch/elasticsearch-audit-events.md +++ b/docs/reference/elasticsearch/elasticsearch-audit-events.md @@ -696,6 +696,7 @@ The schemas of the security config objects mentioned above are as follows. They "full_name": , "email": , "has_password": , "metadata": }`. ``` + % NOTCONSOLE The `full_name`, `email` and `metadata` fields are omitted if empty. @@ -711,6 +712,7 @@ The schemas of the security config objects mentioned above are as follows. They "privileges": , "resources": }], "run_as": , "metadata": }}`. ``` + % NOTCONSOLE The `global`, `field_security`, `except`, `query`, `allow_restricted_indices` and `metadata` fields are omitted if empty. @@ -722,6 +724,7 @@ The schemas of the security config objects mentioned above are as follows. They `{"name": , "roles": , "role_templates": [{"template": , "format": }], "rules": , "enabled": , "metadata": }`. ``` + % NOTCONSOLE The `roles` and `role_templates` fields are omitted if empty. The `rules` object has a recursively nested schema, identical to what is passed in the [API request for mapping roles](docs-content://deploy-manage/users-roles/cluster-or-deployment-auth/mapping-users-groups-to-roles.md). @@ -733,7 +736,7 @@ The schemas of the security config objects mentioned above are as follows. They `{"application": , "name": , "actions": , "metadata": }`. ``` - + % NOTCONSOLE `password` : A simple object like: @@ -741,7 +744,7 @@ The schemas of the security config objects mentioned above are as follows. They ```js `{"user":{"name": }}` ``` - + % NOTCONSOLE `enable` : A simple object like: @@ -749,7 +752,7 @@ The schemas of the security config objects mentioned above are as follows. They ```js `{"user":{"name": }}` ``` - + % NOTCONSOLE `disable` : A simple object like: @@ -757,7 +760,7 @@ The schemas of the security config objects mentioned above are as follows. They ```js `{"user":{"name": }}` ``` - + % NOTCONSOLE `apikey` : An object like: @@ -766,6 +769,7 @@ The schemas of the security config objects mentioned above are as follows. They `{"id": , "name": , "expiration": , "role_descriptors": [], "metadata": []}` ``` + % NOTCONSOLE The `role_descriptors` objects have the same schema as the `role_descriptor` object that is part of the above `role` config object. @@ -779,7 +783,7 @@ The object for an API key update will differ in that it will not include a `name `{"type": , "user": {"name": , "has_password": }, "has_access_token": }` ``` - + % NOTCONSOLE `apikeys` : An object like: @@ -788,6 +792,7 @@ The object for an API key update will differ in that it will not include a `name `{"ids": , "name": , "owned_by_authenticated_user": , "user":{"name": , "realm": }}` ``` + % NOTCONSOLE The object for a bulk API key update will differ in that it will not include `name`, `owned_by_authenticated_user`, or `user`. Instead, it may include `metadata` and `role_descriptors`, which have the same schemas as the fields in the `apikey` config object above. @@ -798,7 +803,8 @@ The object for an API key update will differ in that it will not include a `name ```js `{"namespace":,"service":,"name":}` ``` - + % NOTCONSOLE + ### Extra audit event attributes for specific events [_extra_audit_event_attributes_for_specific_events] There are a few events that have some more attributes in addition to those that have been previously described: diff --git a/docs/reference/elasticsearch/index-lifecycle-actions/ilm-rollover.md b/docs/reference/elasticsearch/index-lifecycle-actions/ilm-rollover.md index d691699448939..ea1fe77ff792d 100644 --- a/docs/reference/elasticsearch/index-lifecycle-actions/ilm-rollover.md +++ b/docs/reference/elasticsearch/index-lifecycle-actions/ilm-rollover.md @@ -151,7 +151,7 @@ PUT _ilm/policy/my_policy } } ``` - +% TEST[skip: deprecated] ### Roll over based on document count [_roll_over_based_on_document_count] @@ -241,7 +241,7 @@ PUT _ilm/policy/my_policy } } ``` - +% TEST[skip: max_size deprecated] ### Roll over while maintaining shard sizes [_roll_over_while_maintaining_shard_sizes] @@ -295,6 +295,6 @@ PUT /_ilm/policy/rollover_policy } } ``` - +% TEST[skip: max_size deprecated] diff --git a/docs/reference/elasticsearch/index-lifecycle-actions/ilm-searchable-snapshot.md b/docs/reference/elasticsearch/index-lifecycle-actions/ilm-searchable-snapshot.md index df12e0f94e344..0e044d9930e53 100644 --- a/docs/reference/elasticsearch/index-lifecycle-actions/ilm-searchable-snapshot.md +++ b/docs/reference/elasticsearch/index-lifecycle-actions/ilm-searchable-snapshot.md @@ -52,6 +52,19 @@ By default, this snapshot is deleted by the [delete action](/reference/elasticse ## Examples [ilm-searchable-snapshot-ex] + + ```console PUT _ilm/policy/my_policy { diff --git a/docs/reference/elasticsearch/index-lifecycle-actions/ilm-wait-for-snapshot.md b/docs/reference/elasticsearch/index-lifecycle-actions/ilm-wait-for-snapshot.md index 9964b1d0dbd67..89941f270118b 100644 --- a/docs/reference/elasticsearch/index-lifecycle-actions/ilm-wait-for-snapshot.md +++ b/docs/reference/elasticsearch/index-lifecycle-actions/ilm-wait-for-snapshot.md @@ -17,6 +17,25 @@ Waits for the specified {{slm-init}} policy to be executed before removing the i ## Example [ilm-wait-for-snapshot-ex] + + ```console PUT _ilm/policy/my_policy { diff --git a/docs/reference/elasticsearch/index-settings/recovery-prioritization.md b/docs/reference/elasticsearch/index-settings/recovery-prioritization.md index 7c03329d24c82..1a6c0bf5c4365 100644 --- a/docs/reference/elasticsearch/index-settings/recovery-prioritization.md +++ b/docs/reference/elasticsearch/index-settings/recovery-prioritization.md @@ -56,4 +56,4 @@ PUT index_4/_settings "index.priority": 1 } ``` - +% TEST[continued] diff --git a/docs/reference/elasticsearch/index-settings/shard-allocation.md b/docs/reference/elasticsearch/index-settings/shard-allocation.md index 629e7072492c8..1bb19f9386f99 100644 --- a/docs/reference/elasticsearch/index-settings/shard-allocation.md +++ b/docs/reference/elasticsearch/index-settings/shard-allocation.md @@ -44,6 +44,7 @@ To filter based on a custom node attribute: "index.routing.allocation.include.size": "big,medium" } ``` + % TEST[s/^/PUT test\n/] If you specify multiple filters the following conditions must be satisfied simultaneously by a node in order for shards to be relocated to it: @@ -60,7 +61,7 @@ To filter based on a custom node attribute: "index.routing.allocation.require.rack": "rack1" } ``` - + % TEST[s/^/PUT test\n/] ## Index allocation filter settings [index-allocation-settings] @@ -110,4 +111,4 @@ PUT test/_settings "index.routing.allocation.include._ip": "192.168.2.*" } ``` - +% TEST[skip:indexes don’t assign] diff --git a/docs/reference/elasticsearch/index-settings/similarity.md b/docs/reference/elasticsearch/index-settings/similarity.md index c1ff8460e7ab6..007dd0d921905 100644 --- a/docs/reference/elasticsearch/index-settings/similarity.md +++ b/docs/reference/elasticsearch/index-settings/similarity.md @@ -49,7 +49,7 @@ PUT /index/_mapping } } ``` - +% TEST[continued] ## Available similarities [_available_similarities] @@ -279,6 +279,8 @@ Which yields: } } ``` +% TESTRESPONSE[s/"took": 12/"took" : $body.took/] +% TESTRESPONSE[s/OzrdjxNtQGaqs4DmioFw9A/$body.hits.hits.0._node/] ::::{warning} While scripted similarities provide a lot of flexibility, there is a set of rules that they need to satisfy. Failing to do so could make Elasticsearch silently return wrong top hits or fail with internal errors at search time: @@ -363,4 +365,4 @@ PUT /index/_settings POST /index/_open ``` - +% TEST[continued] diff --git a/docs/reference/elasticsearch/index-settings/slow-log.md b/docs/reference/elasticsearch/index-settings/slow-log.md index cb8f6d05e8fbf..e3a054d8e807a 100644 --- a/docs/reference/elasticsearch/index-settings/slow-log.md +++ b/docs/reference/elasticsearch/index-settings/slow-log.md @@ -59,6 +59,7 @@ If a call was initiated with an `X-Opaque-ID` header, then the ID is automatical "user.realm": "reserved" } ``` +% NOTCONSOLE The following is an example of an indexing event in the slow log: @@ -85,7 +86,7 @@ The following is an example of an indexing event in the slow log: "user.realm": "reserved" } ``` - +% NOTCONSOLE ## Enable slow logging [enable-slow-log] @@ -143,7 +144,7 @@ PUT /my-index-000001/_settings "index.search.slowlog.include.user": true } ``` - +% TEST[setup:my_index] ### Enable slow logging for indexing events [index-slow-log] @@ -179,7 +180,7 @@ PUT /my-index-000001/_settings "index.indexing.slowlog.include.user": true } ``` - +% TEST[setup:my_index] #### Logging the `_source` field [_logging_the_source_field] diff --git a/docs/reference/elasticsearch/index-settings/sorting.md b/docs/reference/elasticsearch/index-settings/sorting.md index 7c4d09be08ff0..9ef307ccd5ea1 100644 --- a/docs/reference/elasticsearch/index-settings/sorting.md +++ b/docs/reference/elasticsearch/index-settings/sorting.md @@ -142,6 +142,7 @@ GET /events/_search ] } ``` +% TEST[continued] Elasticsearch will detect that the top docs of each segment are already sorted in the index and will only compare the first N documents per segment. The rest of the documents matching the query are collected to count the total number of results and to build aggregations. @@ -157,6 +158,7 @@ GET /events/_search "track_total_hits": false } ``` +% TEST[continued] 1. The index sort will be used to rank the top documents and each segment will early terminate the collection after the first 10 matches. @@ -174,6 +176,8 @@ This time, Elasticsearch will not try to count the number of documents and will "timed_out": false } ``` +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": "$body._shards",/] +% TESTRESPONSE[s/"took": 20,/"took": "$body.took",/] 1. The total number of hits matching the query is unknown because of early termination. diff --git a/docs/reference/elasticsearch/mapping-reference/aggregate-metric-double.md b/docs/reference/elasticsearch/mapping-reference/aggregate-metric-double.md index 61a66a5c1b16b..973c48672b167 100644 --- a/docs/reference/elasticsearch/mapping-reference/aggregate-metric-double.md +++ b/docs/reference/elasticsearch/mapping-reference/aggregate-metric-double.md @@ -113,6 +113,8 @@ PUT stats-index/_doc/2 } } ``` +% TEST[continued] +% TEST[s/_doc\/2/_doc\/2?refresh=wait_for/] You can run `min`, `max`, `sum`, `value_count`, and `avg` aggregations on a `agg_metric` field. @@ -128,6 +130,7 @@ POST stats-index/_search?size=0 } } ``` +% TEST[continued] The aggregation results are based on related metric sub-field values. @@ -153,6 +156,7 @@ The aggregation results are based on related metric sub-field values. } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/] Queries on a `aggregate_metric_double` field use the `default_metric` value. @@ -168,6 +172,7 @@ GET stats-index/_search } } ``` +% TEST[continued] The search returns the following hit. The value of the `default_metric` field, `max`, matches the query value. @@ -198,7 +203,7 @@ The search returns the following hit. The value of the `default_metric` field, ` } } ``` - +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,/] ## Synthetic `_source` [aggregate-metric-double-synthetic-source] @@ -239,6 +244,7 @@ PUT idx/_doc/1 } } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -252,5 +258,5 @@ Will become: } } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/binary.md b/docs/reference/elasticsearch/mapping-reference/binary.md index 41944e28949d6..c4f5f80ed0a3f 100644 --- a/docs/reference/elasticsearch/mapping-reference/binary.md +++ b/docs/reference/elasticsearch/mapping-reference/binary.md @@ -74,6 +74,7 @@ PUT idx/_doc/1 "binary": ["IAA=", "EAA="] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -82,5 +83,5 @@ Will become: "binary": ["EAA=", "IAA="] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/boolean.md b/docs/reference/elasticsearch/mapping-reference/boolean.md index 3c1a8d232233c..16b02174e1498 100644 --- a/docs/reference/elasticsearch/mapping-reference/boolean.md +++ b/docs/reference/elasticsearch/mapping-reference/boolean.md @@ -43,6 +43,7 @@ GET my-index-000001/_search } } ``` +% TEST[s/_search/_search?filter_path=hits.hits/] 1. Indexing a document with `"true"`, which is interpreted as `true`. 2. Searching for documents with a JSON `true`. @@ -82,6 +83,7 @@ GET my-index-000001/_search } } ``` +% TEST[s/_search/_search?filter_path=aggregations,hits.hits/] ## Parameters for `boolean` fields [boolean-params] @@ -155,6 +157,7 @@ PUT idx/_doc/1 "bool": [true, false, true, false] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -163,5 +166,5 @@ Will become: "bool": [false, false, true, true] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/coerce.md b/docs/reference/elasticsearch/mapping-reference/coerce.md index 25e4dd789a7dd..385b78a94bb28 100644 --- a/docs/reference/elasticsearch/mapping-reference/coerce.md +++ b/docs/reference/elasticsearch/mapping-reference/coerce.md @@ -43,6 +43,7 @@ PUT my-index-000001/_doc/2 "number_two": "10" <2> } ``` +% TEST[catch:bad_request] 1. The `number_one` field will contain the integer `10`. 2. This document will be rejected because coercion is disabled. @@ -82,6 +83,7 @@ PUT my-index-000001/_doc/1 PUT my-index-000001/_doc/2 { "number_two": "10" } <2> ``` +% TEST[catch:bad_request] 1. The `number_one` field overrides the index level setting to enable coercion. 2. This document will be rejected because the `number_two` field inherits the index-level coercion setting. diff --git a/docs/reference/elasticsearch/mapping-reference/date.md b/docs/reference/elasticsearch/mapping-reference/date.md index ea00affe941c7..6df76a5702c6b 100644 --- a/docs/reference/elasticsearch/mapping-reference/date.md +++ b/docs/reference/elasticsearch/mapping-reference/date.md @@ -32,6 +32,7 @@ Date formats can be customised, but if no `format` is specified then it uses the ```js "strict_date_optional_time||epoch_millis" ``` +% NOTCONSOLE This means that it will accept dates with optional timestamps, which conform to the formats supported by [`strict_date_optional_time`](/reference/elasticsearch/mapping-reference/mapping-date-format.md#strict-date-time) or milliseconds-since-the-epoch. @@ -163,6 +164,7 @@ POST my-index-000001/_search "_source": false } ``` +% TEST[s/_search/_search?filter_path=hits.hits/] Which will reply with a date like: @@ -213,6 +215,7 @@ PUT idx/_doc/1 "date": ["2015-01-01T12:10:30Z", "2014-01-01T12:10:30Z"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -221,5 +224,5 @@ Will become: "date": ["2014-01-01T12:10:30.000Z", "2015-01-01T12:10:30.000Z"] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/date_nanos.md b/docs/reference/elasticsearch/mapping-reference/date_nanos.md index 1500e8af06910..1f331409e8426 100644 --- a/docs/reference/elasticsearch/mapping-reference/date_nanos.md +++ b/docs/reference/elasticsearch/mapping-reference/date_nanos.md @@ -16,6 +16,7 @@ Date formats can be customised, but if no `format` is specified then it uses the ```js "strict_date_optional_time_nanos||epoch_millis" ``` +% NOTCONSOLE For instance: @@ -59,6 +60,7 @@ GET my-index-000001/_search ] } ``` +% TEST[s/_search/_search?filter_path=hits.hits/] 1. The `date` field uses the default `format`. 2. This document uses a plain date. @@ -112,6 +114,7 @@ PUT idx/_doc/1 "date": ["2015-01-01T12:10:30.000Z", "2014-01-01T12:10:30.000Z"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -120,5 +123,5 @@ Will become: "date": ["2014-01-01T12:10:30.000Z", "2015-01-01T12:10:30.000Z"] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/dense-vector.md b/docs/reference/elasticsearch/mapping-reference/dense-vector.md index 257ed7638bdb9..bff2cc534affa 100644 --- a/docs/reference/elasticsearch/mapping-reference/dense-vector.md +++ b/docs/reference/elasticsearch/mapping-reference/dense-vector.md @@ -445,6 +445,7 @@ POST /my-bit-vectors/_bulk?refresh {"index": {"_id" : "2"}} {"my_vector": "8100012a7f"} <2> ``` +% TEST[continued] 1. 5 bytes representing the 40 bit dimensioned vector 2. A hexidecimal string representing the 40 bit dimensioned vector @@ -463,6 +464,7 @@ POST /my-bit-vectors/_search?filter_path=hits.hits } } ``` +% TEST[continued] ```console-result { @@ -554,6 +556,7 @@ PUT /my-index-000001/_mapping } } ``` +% TEST[setup:my_index] Vectors indexed before this change will keep using the `flat` type (raw float32 representation and brute force search for KNN queries). diff --git a/docs/reference/elasticsearch/mapping-reference/eager-global-ordinals.md b/docs/reference/elasticsearch/mapping-reference/eager-global-ordinals.md index 2265661d0c193..7e8f673328e04 100644 --- a/docs/reference/elasticsearch/mapping-reference/eager-global-ordinals.md +++ b/docs/reference/elasticsearch/mapping-reference/eager-global-ordinals.md @@ -40,6 +40,7 @@ PUT my-index-000001/_mapping } } ``` +% TEST[s/^/PUT my-index-000001\n/] When `eager_global_ordinals` is enabled, global ordinals are built when a shard is [refreshed](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-refresh) — Elasticsearch always loads them before exposing changes to the content of the index. This shifts the cost of building global ordinals from search to index-time. Elasticsearch will also eagerly build global ordinals when creating a new copy of a shard, as can occur when increasing the number of replicas or relocating a shard onto a new node. @@ -56,7 +57,7 @@ PUT my-index-000001/_mapping } } ``` - +% TEST[continued] ## Avoiding global ordinal loading [_avoiding_global_ordinal_loading] diff --git a/docs/reference/elasticsearch/mapping-reference/field-alias.md b/docs/reference/elasticsearch/mapping-reference/field-alias.md index 8e3f49cc8b9de..18e360f30a8f5 100644 --- a/docs/reference/elasticsearch/mapping-reference/field-alias.md +++ b/docs/reference/elasticsearch/mapping-reference/field-alias.md @@ -50,6 +50,7 @@ In some parts of the search request and when requesting field capabilities, fiel ```console GET trips/_field_caps?fields=route_*,transit_mode ``` +% TEST[continued] ## Alias targets [alias-targets] @@ -79,6 +80,7 @@ GET /_search "_source": "route_length_miles" } ``` +% TEST[continued] 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. diff --git a/docs/reference/elasticsearch/mapping-reference/flattened.md b/docs/reference/elasticsearch/mapping-reference/flattened.md index 51a4426fa12d6..209b1ddcb6658 100644 --- a/docs/reference/elasticsearch/mapping-reference/flattened.md +++ b/docs/reference/elasticsearch/mapping-reference/flattened.md @@ -50,6 +50,7 @@ POST bug_reports/_doc/1 } } ``` +% TESTSETUP During indexing, tokens are created for each leaf value in the JSON object. The values are indexed as string keywords, without analysis or special handling for numbers or dates. @@ -154,6 +155,9 @@ POST my-index-000001/_search } } ``` +% TESTRESPONSE[s/"took": 2/"took": $body.took/] +% TESTRESPONSE[s/"max_score" : 1.0/"max_score" : $body.hits.max_score/] +% TESTRESPONSE[s/"_score" : 1.0/"_score" : $body.hits.hits.0._score/] You can also use a [Painless script](docs-content://explore-analyze/scripting/modules-scripting-painless.md) to retrieve values from sub-fields of flattened fields. Instead of including `doc[''].value` in your Painless script, use `doc['.'].value`. For example, if you have a flattened field called `label` with a `release` sub-field, your Painless script would be `doc['labels.release'].value`. @@ -186,6 +190,7 @@ POST /my-index-000001/_bulk?refresh {"index":{}} {"title":"Not urgent","labels":{"priority":"low","release":["v1.2.0"],"timestamp":{"created":1541458026,"closed":1541457010}}} ``` +% TEST[continued] Because `labels` is a `flattened` field type, the entire object is mapped as a single field. To retrieve values from this sub-field in a Painless script, use the `doc['.'].value` format. @@ -267,6 +272,7 @@ PUT idx/_doc/1 } } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -277,6 +283,7 @@ Will become: } } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] Synthetic source always uses nested objects instead of array of objects. For example: @@ -311,6 +318,7 @@ PUT idx/_doc/1 } } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become (note the nested objects instead of the "flattened" array): @@ -324,6 +332,7 @@ Will become (note the nested objects instead of the "flattened" array): } } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] Synthetic source always uses single-valued fields for one-element arrays. For example: @@ -354,6 +363,7 @@ PUT idx/_doc/1 } } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become (note the nested objects instead of the "flattened" array): @@ -364,6 +374,7 @@ Will become (note the nested objects instead of the "flattened" array): } } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] Flattened fields allow for a key to contain both an object and a scalar value. For example, consider the following flattened field `flattened`: @@ -380,6 +391,7 @@ For example, consider the following flattened field `flattened`: } } ``` +% TEST[skip:backporting-from-new-docs] Because `"foo.bar": "10"` is implicitly equivalent to `"foo": { "bar": "10" }`, `"bar"` has both a scalar value `"10"`, and an object value of `{ "baz": "20" }`. @@ -397,3 +409,4 @@ For example, if the field is defined in an index configured with synthetic sourc } } ``` +% TEST[skip:backporting-from-new-docs] \ No newline at end of file diff --git a/docs/reference/elasticsearch/mapping-reference/geo-point.md b/docs/reference/elasticsearch/mapping-reference/geo-point.md index ffeb5874e762b..e89242c0364ce 100644 --- a/docs/reference/elasticsearch/mapping-reference/geo-point.md +++ b/docs/reference/elasticsearch/mapping-reference/geo-point.md @@ -243,6 +243,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -254,5 +255,5 @@ Will become: ] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/geo-shape.md b/docs/reference/elasticsearch/mapping-reference/geo-shape.md index a888102587d67..3e355055f8842 100644 --- a/docs/reference/elasticsearch/mapping-reference/geo-shape.md +++ b/docs/reference/elasticsearch/mapping-reference/geo-shape.md @@ -64,7 +64,7 @@ PUT /example } } ``` - +% TESTSETUP ### Input Structure [input-structure] diff --git a/docs/reference/elasticsearch/mapping-reference/ignore-malformed.md b/docs/reference/elasticsearch/mapping-reference/ignore-malformed.md index 1954070c8fe5b..171e9857e902e 100644 --- a/docs/reference/elasticsearch/mapping-reference/ignore-malformed.md +++ b/docs/reference/elasticsearch/mapping-reference/ignore-malformed.md @@ -42,6 +42,7 @@ PUT my-index-000001/_doc/2 "number_two": "foo" <2> } ``` +% TEST[catch:bad_request] 1. This document will have the `text` field indexed, but not the `number_one` field. 2. This document will be rejected because `number_two` does not allow malformed values. diff --git a/docs/reference/elasticsearch/mapping-reference/index-prefixes.md b/docs/reference/elasticsearch/mapping-reference/index-prefixes.md index 3bf1e2133bc0c..e8d5f50ab5dde 100644 --- a/docs/reference/elasticsearch/mapping-reference/index-prefixes.md +++ b/docs/reference/elasticsearch/mapping-reference/index-prefixes.md @@ -72,4 +72,4 @@ GET my-index-000001/_search } } ``` - +% TEST[continued] diff --git a/docs/reference/elasticsearch/mapping-reference/ip.md b/docs/reference/elasticsearch/mapping-reference/ip.md index eb190d16ce835..01eec88fed78c 100644 --- a/docs/reference/elasticsearch/mapping-reference/ip.md +++ b/docs/reference/elasticsearch/mapping-reference/ip.md @@ -35,6 +35,7 @@ GET my-index-000001/_search } } ``` +% TESTSETUP ::::{note} You can also store ip ranges in a single field using an [ip_range data type](/reference/elasticsearch/mapping-reference/range.md). @@ -151,6 +152,7 @@ PUT idx/_doc/1 "2001:db8::1:0:0:1", "::afff:4567:890a"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -159,6 +161,7 @@ Will become: "ip": ["::afff:4567:890a", "10.10.12.123", "192.168.0.1", "2001:db8::1:0:0:1"] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] ::::{note} IPv4 addresses are sorted as though they were IPv6 addresses prefixed by `::ffff:0:0:0/96` as specified by [rfc6144](https://datatracker.ietf.org/doc/html/rfc6144). diff --git a/docs/reference/elasticsearch/mapping-reference/keyword.md b/docs/reference/elasticsearch/mapping-reference/keyword.md index a642261179dcb..39c977f162545 100644 --- a/docs/reference/elasticsearch/mapping-reference/keyword.md +++ b/docs/reference/elasticsearch/mapping-reference/keyword.md @@ -158,6 +158,7 @@ PUT idx/_doc/1 "kwd": ["foo", "foo", "bar", "baz"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -166,6 +167,7 @@ Will become: "kwd": ["bar", "baz", "foo"] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] If a `keyword` field sets `store` to `true` then order and duplicates are preserved. For example: @@ -194,6 +196,7 @@ PUT idx/_doc/1 "kwd": ["foo", "foo", "bar", "baz"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -202,6 +205,7 @@ Will become: "kwd": ["foo", "foo", "bar", "baz"] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] Values longer than `ignore_above` are preserved but sorted to the end. For example: @@ -230,6 +234,7 @@ PUT idx/_doc/1 "kwd": ["foo", "foo", "bang", "bar", "baz"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -238,6 +243,7 @@ Will become: "kwd": ["bar", "baz", "foo", "bang"] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] If `null_value` is configured, `null` values are replaced with the `null_value` in synthetic source: @@ -266,6 +272,7 @@ PUT idx/_doc/1 "kwd": ["foo", null, "bar"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -318,6 +325,7 @@ POST logs-debug/_doc "message": "Starting up Elasticsearch" } ``` +% TEST[continued] However providing a value that is different from the one configured in the mapping is disallowed. @@ -454,6 +462,7 @@ PUT idx/_doc/1 "card": ["king", "ace", "ace", "jack"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -462,3 +471,4 @@ Will become: "card": ["ace", "jack", "king"] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] \ No newline at end of file diff --git a/docs/reference/elasticsearch/mapping-reference/mapping-doc-count-field.md b/docs/reference/elasticsearch/mapping-reference/mapping-doc-count-field.md index e10cafdb3b921..e882f585c9dd8 100644 --- a/docs/reference/elasticsearch/mapping-reference/mapping-doc-count-field.md +++ b/docs/reference/elasticsearch/mapping-reference/mapping-doc-count-field.md @@ -106,5 +106,5 @@ We will get the following response: } } ``` - +% TESTRESPONSE[skip:test not setup] diff --git a/docs/reference/elasticsearch/mapping-reference/mapping-field-meta.md b/docs/reference/elasticsearch/mapping-reference/mapping-field-meta.md index 33a467e6fbc43..d11189f43e7b1 100644 --- a/docs/reference/elasticsearch/mapping-reference/mapping-field-meta.md +++ b/docs/reference/elasticsearch/mapping-reference/mapping-field-meta.md @@ -22,6 +22,7 @@ PUT my-index-000001 } } ``` +% TEST ::::{note} Field metadata enforces at most 5 entries, that keys have a length that is less than or equal to 20, and that values are strings whose length is less than or equal to 50. diff --git a/docs/reference/elasticsearch/mapping-reference/mapping-meta-field.md b/docs/reference/elasticsearch/mapping-reference/mapping-meta-field.md index 925f2ee108cb5..a5bcd5e37e687 100644 --- a/docs/reference/elasticsearch/mapping-reference/mapping-meta-field.md +++ b/docs/reference/elasticsearch/mapping-reference/mapping-meta-field.md @@ -39,4 +39,4 @@ PUT my-index-000001/_mapping } } ``` - +% TEST[continued] diff --git a/docs/reference/elasticsearch/mapping-reference/mapping-routing-field.md b/docs/reference/elasticsearch/mapping-reference/mapping-routing-field.md index 2c5dfc6c707d8..fe53331b0bcfa 100644 --- a/docs/reference/elasticsearch/mapping-reference/mapping-routing-field.md +++ b/docs/reference/elasticsearch/mapping-reference/mapping-routing-field.md @@ -23,6 +23,7 @@ PUT my-index-000001/_doc/1?routing=user1&refresh=true <1> GET my-index-000001/_doc/1?routing=user1 <2> ``` +% TESTSETUP 1. This document uses `user1` as its routing value, instead of its ID. 2. The same `routing` value needs to be provided when [getting](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get), [deleting](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete), or [updating](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-update) the document. @@ -89,6 +90,7 @@ PUT my-index-000002/_doc/1 <2> "text": "No routing value provided" } ``` +% TEST[catch:bad_request] 1. Routing is required for all documents. 2. This index request throws a `routing_missing_exception`. diff --git a/docs/reference/elasticsearch/mapping-reference/mapping-source-field.md b/docs/reference/elasticsearch/mapping-reference/mapping-source-field.md index ccfd3a0348be2..c0dd3522d3c16 100644 --- a/docs/reference/elasticsearch/mapping-reference/mapping-source-field.md +++ b/docs/reference/elasticsearch/mapping-reference/mapping-source-field.md @@ -39,6 +39,7 @@ PUT idx } } ``` +% TESTSETUP While this on-the-fly reconstruction is *generally* slower than saving the source documents verbatim and loading them at query time, it saves a lot of storage space. Additional latency can be avoided by not loading `_source` field in queries when it is not needed. @@ -80,6 +81,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -90,6 +92,7 @@ Will become: } } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] This can cause some arrays to vanish: @@ -108,6 +111,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -119,7 +123,7 @@ Will become: } } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] #### Fields named as they are mapped [synthetic-source-modifications-field-names] @@ -133,6 +137,7 @@ PUT idx/_doc/1 "foo.bar.baz": 1 } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -145,24 +150,28 @@ Will become: } } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] This impacts how source contents can be referenced in [scripts](docs-content://explore-analyze/scripting/modules-scripting-using.md). For instance, referencing a script in its original source form will return null: ```js "script": { "source": """ emit(params._source['foo.bar.baz']) """ } ``` +% NOTCONSOLE Instead, source references need to be in line with the mapping structure: ```js "script": { "source": """ emit(params._source['foo']['bar']['baz']) """ } ``` +% NOTCONSOLE or simply ```js "script": { "source": """ emit(params._source.foo.bar.baz) """ } ``` +% NOTCONSOLE The following [field APIs](docs-content://explore-analyze/scripting/modules-scripting-fields.md) are preferable as, in addition to being agnostic to the mapping structure, they make use of docvalues if available and fall back to synthetic source only when needed. This reduces source synthesizing, a slow and costly operation. @@ -170,7 +179,7 @@ The following [field APIs](docs-content://explore-analyze/scripting/modules-scri "script": { "source": """ emit(field('foo.bar.baz').get(null)) """ } "script": { "source": """ emit($('foo.bar.baz', null)) """ } ``` - +% NOTCONSOLE #### Alphabetical sorting [synthetic-source-modifications-alphabetical] @@ -225,6 +234,7 @@ PUT idx_keep } } ``` +% TEST $$$synthetic-source-keep-example$$$ @@ -241,6 +251,7 @@ PUT idx_keep/_doc/1 "ids": [ 200, 100, 300, 100 ] } ``` +% TEST[s/$/\nGET idx_keep\/_doc\/1?filter_path=_source\n/] returns the original source, with no array deduplication and sorting: @@ -256,6 +267,7 @@ returns the original source, with no array deduplication and sorting: "ids": [ 200, 100, 300, 100 ] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] The option for capturing the source of arrays can be applied at index level, by setting `index.mapping.synthetic_source_keep` to `arrays`. This applies to all objects and fields in the index, except for the ones with explicit overrides of `synthetic_source_keep` set to `none`. In this case, the storage overhead grows with the number and sizes of arrays present in source of each document, naturally. diff --git a/docs/reference/elasticsearch/mapping-reference/nested.md b/docs/reference/elasticsearch/mapping-reference/nested.md index 4285188f5e8ec..4677353a1f814 100644 --- a/docs/reference/elasticsearch/mapping-reference/nested.md +++ b/docs/reference/elasticsearch/mapping-reference/nested.md @@ -52,6 +52,7 @@ The previous document would be transformed internally into a document that looks "user.last" : [ "smith", "white" ] } ``` +% NOTCONSOLE The `user.first` and `user.last` fields are flattened into multi-value fields, and the association between `alice` and `white` is lost. This document would incorrectly match a query for `alice AND smith`: @@ -68,6 +69,7 @@ GET my-index-000001/_search } } ``` +% TEST[continued] ## Using `nested` fields for arrays of objects [nested-fields-array-objects] diff --git a/docs/reference/elasticsearch/mapping-reference/normalizer.md b/docs/reference/elasticsearch/mapping-reference/normalizer.md index aa219956e9c56..f67442850c3ac 100644 --- a/docs/reference/elasticsearch/mapping-reference/normalizer.md +++ b/docs/reference/elasticsearch/mapping-reference/normalizer.md @@ -110,6 +110,7 @@ The above queries match documents 1 and 2 since `BÀR` is converted to `bar` at } } ``` +% TESTRESPONSE[s/"took".*/"took": "$body.took",/] Also, the fact that keywords are converted prior to indexing also means that aggregations return normalized values: @@ -126,6 +127,7 @@ GET index/_search } } ``` +% TEST[continued] returns @@ -165,4 +167,4 @@ returns } } ``` - +% TESTRESPONSE[s/"took".*/"took": "$body.took",/] diff --git a/docs/reference/elasticsearch/mapping-reference/norms.md b/docs/reference/elasticsearch/mapping-reference/norms.md index aa004d6716dfa..bcdc82a136249 100644 --- a/docs/reference/elasticsearch/mapping-reference/norms.md +++ b/docs/reference/elasticsearch/mapping-reference/norms.md @@ -27,6 +27,7 @@ PUT my-index-000001/_mapping } } ``` +% TEST[s/^/PUT my-index-000001\n/] ::::{note} Norms will not be removed instantly, but will be removed as old segments are merged into new segments as you continue indexing new documents. Any score computation on a field that has had norms removed might return inconsistent results since some documents won’t have norms anymore while other documents might still have norms. diff --git a/docs/reference/elasticsearch/mapping-reference/number.md b/docs/reference/elasticsearch/mapping-reference/number.md index 1b220bbc48fda..808ae5e77141b 100644 --- a/docs/reference/elasticsearch/mapping-reference/number.md +++ b/docs/reference/elasticsearch/mapping-reference/number.md @@ -208,6 +208,7 @@ PUT idx/_doc/1 "long": [0, 0, -123466, 87612] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -216,6 +217,7 @@ Will become: "long": [-123466, 0, 0, 87612] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] Scaled floats will always apply their scaling factor so: @@ -244,6 +246,7 @@ PUT idx/_doc/1 "f": 123 } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -252,5 +255,5 @@ Will become: "f": 100.0 } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/object.md b/docs/reference/elasticsearch/mapping-reference/object.md index a44d77becd290..dc018294a0e33 100644 --- a/docs/reference/elasticsearch/mapping-reference/object.md +++ b/docs/reference/elasticsearch/mapping-reference/object.md @@ -38,6 +38,7 @@ Internally, this document is indexed as a simple, flat list of key-value pairs, "manager.name.last": "Smith" } ``` +% NOTCONSOLE An explicit mapping for the above document could look like this: diff --git a/docs/reference/elasticsearch/mapping-reference/parent-join.md b/docs/reference/elasticsearch/mapping-reference/parent-join.md index 08ee7ac490fdc..6a623c4aecdea 100644 --- a/docs/reference/elasticsearch/mapping-reference/parent-join.md +++ b/docs/reference/elasticsearch/mapping-reference/parent-join.md @@ -61,6 +61,7 @@ PUT my-index-000001/_doc/2?refresh } } ``` +% TEST[continued] 1. This document is a `question` document. @@ -82,6 +83,7 @@ PUT my-index-000001/_doc/2?refresh "my_join_field": "question" } ``` +% TEST[continued] 1. Simpler notation for a parent document just uses the relation name. @@ -116,6 +118,7 @@ PUT my-index-000001/_doc/4?routing=1&refresh } } ``` +% TEST[continued] 1. The routing value is mandatory because parent and child documents must be indexed on the same shard 2. `answer` is the name of the join for this document @@ -157,6 +160,7 @@ GET my-index-000001/_search "sort": ["my_id"] } ``` +% TEST[continued] Will return: @@ -234,6 +238,7 @@ Will return: } } ``` +% TESTRESPONSE[s/\.\.\./"timed_out": false, "took": $body.took, "_shards": $body._shards/] 1. This document belongs to the `question` join 2. This document belongs to the `question` join @@ -278,6 +283,8 @@ GET my-index-000001/_search ] } ``` +% TEST[continued] +% TEST[s/_search/_search?filter_path=aggregations,hits.hits&sort=my_id/] 1. Querying the `parent id` field (also see the [`has_parent` query](/reference/query-languages/query-dsl/query-dsl-has-parent-query.md) and the [`has_child` query](/reference/query-languages/query-dsl/query-dsl-has-child-query.md)) 2. Aggregating on the `parent id` field (also see the [`children`](/reference/aggregations/search-aggregations-bucket-children-aggregation.md) aggregation) @@ -319,7 +326,7 @@ GET _stats/fielddata?human&fields=my_join_field#question # Per-node per-index GET _nodes/stats/indices/fielddata?human&fields=my_join_field#question ``` - +% TEST[continued] ## Multiple children per parent [_multiple_children_per_parent] @@ -398,6 +405,7 @@ PUT my-index-000001/_doc/3?routing=1&refresh <1> } } ``` +% TEST[continued] 1. This child document must be on the same shard than its grand-parent and parent 2. The parent id of this document (must points to an `answer` document) diff --git a/docs/reference/elasticsearch/mapping-reference/passthrough.md b/docs/reference/elasticsearch/mapping-reference/passthrough.md index 0d30a7b2f4984..0272583a21ec5 100644 --- a/docs/reference/elasticsearch/mapping-reference/passthrough.md +++ b/docs/reference/elasticsearch/mapping-reference/passthrough.md @@ -163,6 +163,7 @@ POST metrics-mymetrics-test/_doc "cpu": 10 } ``` +% TEST[skip: The @timestamp value won’t match an accepted range in the TSDS] In the example above, `attributes` is defined as a dimension container. Its sub-fields `host.name` (static) and `zone` (dynamic) get included in the routing path and tsid, and can be referenced in queries without the `attributes.` prefix. diff --git a/docs/reference/elasticsearch/mapping-reference/percolator.md b/docs/reference/elasticsearch/mapping-reference/percolator.md index d2ccc61e690d8..7776771094dca 100644 --- a/docs/reference/elasticsearch/mapping-reference/percolator.md +++ b/docs/reference/elasticsearch/mapping-reference/percolator.md @@ -28,6 +28,7 @@ PUT my-index-000001 } } ``` +% TESTSETUP Then you can index a query: @@ -91,6 +92,7 @@ PUT queries/_doc/1?refresh } } ``` +% TEST[continued] 1. It is always recommended to define an alias for your index, so that in case of a reindex systems / applications don’t need to be changed to know that the percolator queries are now in a different index. @@ -140,6 +142,7 @@ POST _aliases ] } ``` +% TEST[continued] 1. If you have an alias don’t forget to point it to the new index. @@ -159,6 +162,7 @@ GET /queries/_search } } ``` +% TEST[continued] now returns matches from the new index: @@ -198,6 +202,7 @@ now returns matches from the new index: } } ``` +% TESTRESPONSE[s/"took": 3,/"took": "$body.took",/] 1. Percolator query hit is now being presented from the new index. @@ -224,6 +229,7 @@ Lets say we want to index the following percolator query: } } ``` +% NOTCONSOLE with these settings and mapping: @@ -253,6 +259,7 @@ PUT /test_index } } ``` +% TEST[continued] 1. For the purpose of this example, this analyzer is considered expensive. @@ -266,6 +273,7 @@ POST /test_index/_analyze "text" : "missing bicycles" } ``` +% TEST[continued] This results the following response: @@ -305,6 +313,7 @@ PUT /test_index/_doc/1?refresh } } ``` +% TEST[continued] 1. It is important to select a whitespace analyzer here, otherwise the analyzer defined in the mapping will be used, which defeats the point of using this workflow. Note that `whitespace` is a built-in analyzer, if a different analyzer needs to be used, it needs to be configured first in the index’s settings. @@ -326,6 +335,7 @@ GET /test_index/_search } } ``` +% TEST[continued] This results in a response like this: @@ -368,7 +378,7 @@ This results in a response like this: } } ``` - +% TESTRESPONSE[s/"took": 6,/"took": "$body.took",/] ## Optimizing wildcard queries. [_optimizing_wildcard_queries] @@ -421,6 +431,7 @@ PUT my_queries1 } } ``` +% TEST[continued] 1. The analyzer that generates the prefix tokens to be used at index time only. 2. Increase the `min_gram` and decrease `max_gram` settings based on your prefix search needs. @@ -438,6 +449,7 @@ Then instead of indexing the following query: } } ``` +% NOTCONSOLE this query below should be indexed: @@ -451,6 +463,7 @@ PUT /my_queries1/_doc/1?refresh } } ``` +% TEST[continued] This way can handle the second query more efficiently than the first query. @@ -469,6 +482,7 @@ GET /my_queries1/_search } } ``` +% TEST[continued] ```console-result { @@ -508,6 +522,7 @@ GET /my_queries1/_search } } ``` +% TESTRESPONSE[s/"took": 6,/"took": "$body.took",/] The same technique can also be used to speed up suffix wildcard searches. By using the `reverse` token filter before the `edge_ngram` token filter. @@ -563,6 +578,7 @@ PUT my_queries2 } } ``` +% TEST[continued] 1. A custom analyzer is needed at search time too, because otherwise the query terms are not being reversed and would otherwise not match with the reserved suffix tokens. @@ -578,6 +594,7 @@ Then instead of indexing the following query: } } ``` +% NOTCONSOLE the following query below should be indexed: @@ -591,6 +608,7 @@ PUT /my_queries2/_doc/2?refresh } } ``` +% TEST[continued] 1. The `match` query should be used instead of the `term` query, because text analysis needs to reverse the query terms. @@ -610,7 +628,7 @@ GET /my_queries2/_search } } ``` - +% TEST[continued] ## Dedicated Percolator Index [_dedicated_percolator_index] diff --git a/docs/reference/elasticsearch/mapping-reference/properties.md b/docs/reference/elasticsearch/mapping-reference/properties.md index 4d8a6a6c5bfe8..07dce9352ae19 100644 --- a/docs/reference/elasticsearch/mapping-reference/properties.md +++ b/docs/reference/elasticsearch/mapping-reference/properties.md @@ -95,6 +95,7 @@ GET my-index-000001/_search } } ``` +% TEST[continued] ::::{important} The full path to the inner field must be specified. diff --git a/docs/reference/elasticsearch/mapping-reference/range.md b/docs/reference/elasticsearch/mapping-reference/range.md index b11edc7e4102c..4ad2315a66ce5 100644 --- a/docs/reference/elasticsearch/mapping-reference/range.md +++ b/docs/reference/elasticsearch/mapping-reference/range.md @@ -62,6 +62,7 @@ PUT range_index/_doc/1?refresh } } ``` +% TESTSETUP 1. `date_range` types accept the same field parameters defined by the [`date`](/reference/elasticsearch/mapping-reference/date.md) type. 2. Example indexing a meeting with 10 to 20 attendees, not including 20. @@ -119,6 +120,7 @@ The result produced by the above query. } } ``` +% TESTRESPONSE[s/"took": 13/"took" : $body.took/] The following is an example of a `date_range` query over the `date_range` field named "time_frame". @@ -177,6 +179,7 @@ This query produces a similar result: } } ``` +% TESTRESPONSE[s/"took": 13/"took" : $body.took/] ## IP Range [ip-range] @@ -329,6 +332,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -350,6 +354,7 @@ Will become: ] } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] Values of `ip_range` fields are not sorted but original order is not preserved. Duplicate ranges are removed. If `ip_range` field value is provided as a CIDR, it will be represented as a range of IP addresses in synthetic source. @@ -387,6 +392,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -399,6 +405,7 @@ Will become: } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] $$$range-synthetic-source-inclusive$$$ Range field values are always represented as inclusive on both sides with bounds adjusted accordingly. Default values for range bounds are represented as `null`. This is true even if range bound was explicitly provided. For example: @@ -432,6 +439,7 @@ PUT idx/_doc/1 } } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -443,6 +451,7 @@ Will become: } } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] $$$range-synthetic-source-default-bounds$$$ Default values for range bounds are represented as `null` in synthetic source. This is true even if range bound was explicitly provided with default value. For example: @@ -475,6 +484,7 @@ PUT idx/_doc/1 } } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -486,6 +496,7 @@ Will become: } } ``` +% TEST[s/^/{"_source":/ s/\n$/}/] `date` ranges are formatted using provided `format` or by default using `yyyy-MM-dd'T'HH:mm:ss.SSSZ` format. For example: @@ -524,6 +535,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -541,5 +553,5 @@ Will become: ] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/mapping-reference/rank-vectors.md b/docs/reference/elasticsearch/mapping-reference/rank-vectors.md index 4240b029ff5bb..be7a365853137 100644 --- a/docs/reference/elasticsearch/mapping-reference/rank-vectors.md +++ b/docs/reference/elasticsearch/mapping-reference/rank-vectors.md @@ -32,6 +32,7 @@ PUT my-rank-vectors-float/_doc/1 "my_vector" : [[0.5, 10, 6], [-0.5, 10, 10]] } ``` +% TESTSETUP In addition to the `float` element type, `byte` and `bit` element types are also supported. diff --git a/docs/reference/elasticsearch/mapping-reference/search-as-you-type.md b/docs/reference/elasticsearch/mapping-reference/search-as-you-type.md index 8cf1bd70086c3..a0798c163ed9b 100644 --- a/docs/reference/elasticsearch/mapping-reference/search-as-you-type.md +++ b/docs/reference/elasticsearch/mapping-reference/search-as-you-type.md @@ -50,6 +50,7 @@ PUT my-index-000001/_doc/1?refresh "my_field": "quick brown fox jump lazy dog" } ``` +% TEST[continued] The most efficient way of querying to serve a search-as-you-type use case is usually a [`multi_match`](/reference/query-languages/query-dsl/query-dsl-multi-match-query.md) query of type [`bool_prefix`](/reference/query-languages/query-dsl/query-dsl-match-bool-prefix-query.md) that targets the root `search_as_you_type` field and its shingle subfields. This can match the query terms in any order, but will score documents higher if they contain the terms in order in a shingle subfield. @@ -76,6 +77,7 @@ GET my-index-000001/_search } } ``` +% TEST[continued] 1. Adding "my_field._index_prefix" to the `matched_fields` allows to highlight "my_field" also based on matches from "my_field._index_prefix" field. @@ -114,6 +116,9 @@ GET my-index-000001/_search } } ``` +% TESTRESPONSE[s/"took" : 44/"took" : $body.took/] +% TESTRESPONSE[s/"max_score" : 0.8630463/"max_score" : $body.hits.max_score/] +% TESTRESPONSE[s/"_score" : 0.8630463/"_score" : $body.hits.hits.0._score/] To search for documents that strictly match the query terms in order, or to search using other properties of phrase queries, use a [`match_phrase_prefix` query](/reference/query-languages/query-dsl/query-dsl-match-query-phrase-prefix.md) on the root field. A [`match_phrase` query](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) can also be used if the last term should be matched exactly, and not as a prefix. Using phrase queries may be less efficient than using the `match_bool_prefix` query. @@ -127,6 +132,7 @@ GET my-index-000001/_search } } ``` +% TEST[continued] ## Parameters specific to the `search_as_you_type` field [specific-params] diff --git a/docs/reference/elasticsearch/mapping-reference/semantic-text.md b/docs/reference/elasticsearch/mapping-reference/semantic-text.md index 5ef7bca014d60..c51d7382f33c5 100644 --- a/docs/reference/elasticsearch/mapping-reference/semantic-text.md +++ b/docs/reference/elasticsearch/mapping-reference/semantic-text.md @@ -60,6 +60,7 @@ PUT my-index-000001 } } ``` +% TEST[skip:Requires inference endpoint] ### Using a custom endpoint @@ -81,6 +82,7 @@ PUT my-index-000002 } } ``` +% TEST[skip:Requires inference endpoint] 1. The `inference_id` of the {{infer}} endpoint to use to generate embeddings. @@ -105,6 +107,7 @@ PUT my-index-000003 } } ``` +% TEST[skip:Requires inference endpoint] ### Using ELSER on EIS ```{applies_to} @@ -128,6 +131,7 @@ PUT my-index-000001 } } ``` +% TEST[skip:Requires inference endpoint] ::::{note} While we do encourage experimentation, we do not recommend implementing production use cases on top of this feature while it is in Technical Preview. @@ -311,6 +315,7 @@ POST test-index/_search ] } ``` +% TEST[skip:Requires inference endpoint] 1. Use `"format": "chunks"` to return the field’s text as the original text chunks that were indexed. @@ -338,6 +343,7 @@ POST test-index/_search } } ``` +% TEST[skip:Requires inference endpoint] 1. Specifies the maximum number of fragments to return. 2. Sorts the most relevant highlighted fragments by score when set to `score`. By default, @@ -367,6 +373,7 @@ POST test-index/_search } } ``` +% TEST[skip:Requires inference endpoint] 1. Ensures that highlighting is applied exclusively to semantic_text fields. @@ -392,6 +399,7 @@ POST test-index/_search } } ``` +% TEST[skip:Requires inference endpoint] 1. Returns the first 5 fragments. Increase this value to retrieve additional fragments. @@ -441,6 +449,7 @@ POST my-index/_search } } ``` +% TEST[skip:Requires inference endpoint] The embeddings will appear under `_inference_fields` in `_source`. @@ -467,6 +476,7 @@ POST _reindex } } ``` +% TEST[skip:Requires inference endpoint] 1. Sends the source documents with their stored embeddings to the destination index. @@ -497,6 +507,7 @@ POST test-index/_search ] } ``` +% TEST[skip:Requires inference endpoint] This returns the chunked embeddings used for semantic search under `_inference_fields` in `_source`. Note that the `fields` option is **not** available for the Reindex API. @@ -546,6 +557,7 @@ PUT my-index-000004 } } ``` +% TEST[skip:Requires inference endpoint] ## Updates to `semantic_text` fields [update-script] @@ -589,6 +601,7 @@ PUT test-index } } ``` +% TEST[skip:Requires inference endpoint] can also be declared as multi-fields: @@ -610,6 +623,7 @@ PUT test-index } } ``` +% TEST[skip:Requires inference endpoint] ## Querying `semantic_text` fields [querying-semantic-text-fields] @@ -654,6 +668,7 @@ POST test-index/_search ] } ``` +% TEST[skip:Requires inference endpoint] This will return verbose chunked embeddings content that is used to perform semantic search for `semantic_text` fields. diff --git a/docs/reference/elasticsearch/mapping-reference/shape.md b/docs/reference/elasticsearch/mapping-reference/shape.md index e42e7b2966f6f..e433d5d017bb6 100644 --- a/docs/reference/elasticsearch/mapping-reference/shape.md +++ b/docs/reference/elasticsearch/mapping-reference/shape.md @@ -47,6 +47,7 @@ PUT /example } } ``` +% TESTSETUP 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). diff --git a/docs/reference/elasticsearch/mapping-reference/text.md b/docs/reference/elasticsearch/mapping-reference/text.md index 612ce067cd4b3..ed9bff0c7e3b5 100644 --- a/docs/reference/elasticsearch/mapping-reference/text.md +++ b/docs/reference/elasticsearch/mapping-reference/text.md @@ -147,6 +147,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -159,7 +160,7 @@ Will become: ] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] If the `text` field sets `store` to `true` then the sub-field is not used and no modifications are applied. For example: @@ -200,6 +201,7 @@ PUT idx/_doc/1 ] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -212,7 +214,7 @@ Will become: ] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] ## `fielddata` mapping parameter [fielddata-mapping-param] @@ -270,6 +272,7 @@ PUT my-index-000001/_mapping } } ``` +% TEST[continued] 1. The mapping that you specify for `my_field` should consist of the existing mapping for that field, plus the `fielddata` parameter. diff --git a/docs/reference/elasticsearch/mapping-reference/unsigned-long.md b/docs/reference/elasticsearch/mapping-reference/unsigned-long.md index e76c8289ce636..45b5a93c78180 100644 --- a/docs/reference/elasticsearch/mapping-reference/unsigned-long.md +++ b/docs/reference/elasticsearch/mapping-reference/unsigned-long.md @@ -35,6 +35,7 @@ POST /my_index/_bulk?refresh {"index":{"_id":4}} {"my_counter": 18446744073709551615} ``` +% TEST[continued] Term queries accept any numbers in a numeric or string form. @@ -48,6 +49,7 @@ GET /my_index/_search } } ``` +% TEST[continued] Range query terms can contain values with decimal parts. In this case {{es}} converts them to integer values: `gte` and `gt` terms are converted to the nearest integer up inclusive, and `lt` and `lte` ranges are converted to the nearest integer down inclusive. @@ -66,6 +68,7 @@ GET /my_index/_search } } ``` +% TEST[continued] ## Sort values [_sort_values_2] @@ -85,7 +88,7 @@ GET /my_index/_search "sort" : {"my_counter" : "desc"} } ``` - +% TEST[continued] ## Stored fields [_stored_fields] @@ -118,6 +121,7 @@ GET /my_index/_search } } ``` +% TEST[continued] Alternatively, you can treat the unsigned long type as `BigInteger` in your scripts by using the field API. For example, this script treats `my_counter` as `BigInteger` with a default value of `BigInteger.ZERO`: @@ -126,6 +130,7 @@ Alternatively, you can treat the unsigned long type as `BigInteger` in your scri "source": "field('my_counter').asBigInteger(BigInteger.ZERO)" } ``` +% NOTCONSOLE For scripts that need to return float or double values, you can further convert `BigInteger` values to double or float: @@ -142,7 +147,7 @@ GET /my_index/_search } } ``` - +% TEST[continued] ## Queries with mixed numeric types [_queries_with_mixed_numeric_types] diff --git a/docs/reference/elasticsearch/mapping-reference/version.md b/docs/reference/elasticsearch/mapping-reference/version.md index 9abddaedb848f..9d72beee8154b 100644 --- a/docs/reference/elasticsearch/mapping-reference/version.md +++ b/docs/reference/elasticsearch/mapping-reference/version.md @@ -72,6 +72,7 @@ PUT idx/_doc/1 "versions": ["8.0.0-beta1", "8.5.0", "0.90.12", "2.6.1", "1.3.4", "1.3.4"] } ``` +% TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/] Will become: @@ -80,5 +81,5 @@ Will become: "versions": ["0.90.12", "1.3.4", "2.6.1", "8.0.0-beta1", "8.5.0"] } ``` - +% TEST[s/^/{"_source":/ s/\n$/}/] diff --git a/docs/reference/elasticsearch/rest-apis/api-conventions.md b/docs/reference/elasticsearch/rest-apis/api-conventions.md index 5ba1e7720064d..d66f89768bc89 100644 --- a/docs/reference/elasticsearch/rest-apis/api-conventions.md +++ b/docs/reference/elasticsearch/rest-apis/api-conventions.md @@ -273,7 +273,8 @@ GET /%3Clogstash-%7Bnow%2Fd-2d%7D%3E%2C%3Clogstash-%7Bnow%2Fd-1d%7D%3E%2C%3Clogs } } ``` - +% TEST[s/^/PUT logstash-2016.09.20\nPUT logstash-2016.09.19\nPUT logstash-2016.09.18\n/] +% TEST[s/now/2016.09.20%7C%7C/] ## Multi-target syntax [api-multi-index] @@ -455,7 +456,7 @@ GET remote-cluster:logs-*-*::failures/_search GET *::data,*::failures,-logs-rdbms-*::failures/_stats GET ::failures/_search ``` - +% TEST[skip:backport] ## Parameters [api-conventions-parameters] diff --git a/docs/reference/elasticsearch/rest-apis/collapse-search-results.md b/docs/reference/elasticsearch/rest-apis/collapse-search-results.md index c238daa0b80a6..e3f8fef6403af 100644 --- a/docs/reference/elasticsearch/rest-apis/collapse-search-results.md +++ b/docs/reference/elasticsearch/rest-apis/collapse-search-results.md @@ -33,6 +33,7 @@ GET my-index-000001/_search "from": 0 <3> } ``` +% TEST[setup:my_index] 1. Collapse the result set using the `user.id` field 2. Sort the results by `http.response.bytes` @@ -82,6 +83,7 @@ GET /my-index-000001/_search ] } ``` +% TEST[setup:my_index] 1. Collapse the result set using the `user.id` field 2. The name used for the inner hit section in the response @@ -134,6 +136,7 @@ GET /my-index-000001/_search ] } ``` +% TEST[setup:my_index] 1. Collapse the result set using the `user.id` field 2. Return the three largest HTTP responses for the user @@ -169,7 +172,7 @@ GET /my-index-000001/_search "search_after": ["dd5ce1ad"] } ``` - +% TEST[setup:my_index] ## Rescore collapse results [rescore-collapse-results] @@ -183,6 +186,7 @@ POST /my-index-000001/_doc?routing=xyz <1> "user.id": "xyz" } ``` +% TEST[setup:my_index] 1. Assign routing with the collapse field value (`user.id`). @@ -216,6 +220,7 @@ GET /my-index-000001/_search } } ``` +% TEST[setup:my_index] ::::{warning} Rescorers are not applied to [`inner hits`](/reference/elasticsearch/rest-apis/retrieve-inner-hits.md). @@ -252,6 +257,8 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] +% TEST[s/_search/_search\?filter_path=hits.hits/] ```console-result { diff --git a/docs/reference/elasticsearch/rest-apis/common-options.md b/docs/reference/elasticsearch/rest-apis/common-options.md index 44e9abb580cda..153dbafbb0c3b 100644 --- a/docs/reference/elasticsearch/rest-apis/common-options.md +++ b/docs/reference/elasticsearch/rest-apis/common-options.md @@ -79,6 +79,7 @@ All REST APIs accept a `filter_path` parameter that can be used to reduce the re ```console GET /_search?q=kimchy&filter_path=took,hits.hits._id,hits.hits._score ``` +% TEST[setup:my_index] Responds: @@ -95,12 +96,15 @@ Responds: } } ``` +% TESTRESPONSE[s/"took" : 3/"took" : $body.took/] +% TESTRESPONSE[s/1.6375021/$body.hits.hits.0._score/] It also supports the `*` wildcard character to match any field or part of a field’s name: ```console GET /_cluster/state?filter_path=metadata.indices.*.stat* ``` +% TEST[s/^/PUT my-index-000001\n/] Responds: @@ -119,6 +123,7 @@ And the `**` wildcard can be used to include fields without knowing the exact pa ```console GET /_cluster/state?filter_path=routing_table.indices.**.state ``` +% TEST[s/^/PUT my-index-000001\n/] Responds: @@ -141,6 +146,7 @@ It is also possible to exclude one or more fields by prefixing the filter with t ```console GET /_count?filter_path=-_shards ``` +% TEST[setup:my_index] Responds: @@ -155,6 +161,7 @@ And for more control, both inclusive and exclusive filters can be combined in th ```console GET /_cluster/state?filter_path=metadata.indices.*.state,-metadata.indices.logstash-* ``` +% TEST[s/^/PUT my-index-000001\nPUT my-index-000002\nPUT my-index-000003\nPUT logstash-2016.01\n/] Responds: @@ -204,6 +211,7 @@ The `flat_settings` flag affects rendering of the lists of settings. When the `f ```console GET my-index-000001/_settings?flat_settings=true ``` +% TEST[setup:my_index] Returns: @@ -222,12 +230,16 @@ Returns: } } ``` +% TESTRESPONSE[s/1474389951325/$body.my-index-000001.settings.index\\\\.creation_date/] +% TESTRESPONSE[s/n6gzFZTgS664GUfx0Xrpjw/$body.my-index-000001.settings.index\\\\.uuid/] +% TESTRESPONSE[s/"index.version.created": \.\.\./"index.version.created": $body.my-index-000001.settings.index\\\\.version\\\\.created/] When the `flat_settings` flag is `false`, settings are returned in a more human readable structured format: ```console GET my-index-000001/_settings?flat_settings=false ``` +% TEST[setup:my_index] Returns: @@ -256,6 +268,9 @@ Returns: } } ``` +% TESTRESPONSE[s/1474389951325/$body.my-index-000001.settings.index.creation_date/] +% TESTRESPONSE[s/n6gzFZTgS664GUfx0Xrpjw/$body.my-index-000001.settings.index.uuid/] +% TESTRESPONSE[s/"created": \.\.\./"created": $body.my-index-000001.settings.index.version.created/] By default `flat_settings` is set to `false`. @@ -294,6 +309,7 @@ By default when a request returns an error Elasticsearch doesn’t include the s ```console POST /my-index-000001/_search?size=surprise_me ``` +% TEST[s/surprise_me/surprise_me&error_trace=false/ catch:bad_request] The response looks like: @@ -322,6 +338,7 @@ But if you set `error_trace=true`: ```console POST /my-index-000001/_search?size=surprise_me&error_trace=true ``` +% TEST[catch:bad_request] The response looks like: @@ -347,4 +364,6 @@ The response looks like: "status": 400 } ``` - +% TESTRESPONSE[s/"stack_trace": "Failed to parse int parameter.+\.\.\."/"stack_trace": $body.error.root_cause.0.stack_trace/] +% TESTRESPONSE[s/"stack_trace": "java.lang.IllegalArgum.+\.\.\."/"stack_trace": $body.error.stack_trace/] +% TESTRESPONSE[s/"stack_trace": "java.lang.Number.+\.\.\."/"stack_trace": $body.error.caused_by.stack_trace/] diff --git a/docs/reference/elasticsearch/rest-apis/create-index-from-source.md b/docs/reference/elasticsearch/rest-apis/create-index-from-source.md index 639aac329aeab..6ea684baf1d34 100644 --- a/docs/reference/elasticsearch/rest-apis/create-index-from-source.md +++ b/docs/reference/elasticsearch/rest-apis/create-index-from-source.md @@ -75,6 +75,7 @@ PUT /my-index } } ``` +% TESTSETUP Now we create a destination index from the source index. This new index will have the same mappings and settings as the source index. diff --git a/docs/reference/elasticsearch/rest-apis/filter-search-results.md b/docs/reference/elasticsearch/rest-apis/filter-search-results.md index 6bfa11f8cd0b1..6fdc96f9c5ee5 100644 --- a/docs/reference/elasticsearch/rest-apis/filter-search-results.md +++ b/docs/reference/elasticsearch/rest-apis/filter-search-results.md @@ -37,6 +37,7 @@ PUT /shirts/_doc/1?refresh "model": "slim" } ``` +% TESTSETUP Imagine a user has specified two filters: diff --git a/docs/reference/elasticsearch/rest-apis/find-text-structure-examples.md b/docs/reference/elasticsearch/rest-apis/find-text-structure-examples.md index cad5c092666fb..d23e5891f8934 100644 --- a/docs/reference/elasticsearch/rest-apis/find-text-structure-examples.md +++ b/docs/reference/elasticsearch/rest-apis/find-text-structure-examples.md @@ -14,7 +14,6 @@ The next example shows how it's possible to find the structure of some New York ``` curl -s "s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_2018-06.csv" | head -20000 | curl -s -H "Content-Type: application/json" -XPOST "localhost:9200/_text_structure/find_structure?pretty&lines_to_sample=20000" -T - ``` - % NOTCONSOLE % Not converting to console because this shows how curl can be used @@ -306,7 +305,6 @@ If the request does not encounter errors, you receive the following result: } } ``` - % NOTCONSOLE 1. `num_messages_analyzed` is 2 lower than `num_lines_analyzed` because only data records count as messages. The first line contains the column names and in this sample the second line is blank. @@ -327,7 +325,6 @@ If you try to analyze a lot of data then the analysis will take a long time. If ``` curl -s "s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_2018-06.csv" | head -200000 | curl -s -H "Content-Type: application/json" -XPOST "localhost:9200/_text_structure/find_structure?pretty&lines_to_sample=200000&timeout=1s" -T - ``` - % NOTCONSOLE % Not converting to console because this shows how curl can be used @@ -348,7 +345,6 @@ Unless you are using an incredibly fast computer you'll receive a timeout error: "status" : 500 } ``` - % NOTCONSOLE ::::{note} @@ -363,7 +359,6 @@ This is an example of analyzing an {{es}} log file: curl -s -H "Content-Type: application/json" -XPOST "localhost:9200/_text_structure/find_structure?pretty&ecs_compatibility=disabled" -T "$ES_HOME/logs/elasticsearch.log" ``` - % NOTCONSOLE % Not converting to console because this shows how curl can be used @@ -498,7 +493,6 @@ If the request does not encounter errors, the result will look something like th } } ``` - % NOTCONSOLE 1. This time the `format` has been identified as `semi_structured_text`. @@ -515,7 +509,6 @@ In the case of the {{es}} log a more complete Grok pattern is `\[%{TIMESTAMP_ISO ``` curl -s -H "Content-Type: application/json" -XPOST "localhost:9200/_text_structure/find_structure?pretty&format=semi_structured_text&grok_pattern=%5C%5B%25%7BTIMESTAMP_ISO8601:timestamp%7D%5C%5D%5C%5B%25%7BLOGLEVEL:loglevel%7D%20*%5C%5D%5C%5B%25%7BJAVACLASS:class%7D%20*%5C%5D%20%5C%5B%25%7BHOSTNAME:node%7D%5C%5D%20%25%7BJAVALOGMESSAGE:message%7D" -T "$ES_HOME/logs/elasticsearch.log" ``` - % NOTCONSOLE % Not converting to console because this shows how curl can be used @@ -758,7 +751,6 @@ If the request does not encounter errors, the result will look something like th } } ``` - % NOTCONSOLE 1. The `grok_pattern` in the output is now the overridden one supplied in the query parameter. diff --git a/docs/reference/elasticsearch/rest-apis/highlighting-examples.md b/docs/reference/elasticsearch/rest-apis/highlighting-examples.md index fc3070ee05c06..31b40f187552b 100644 --- a/docs/reference/elasticsearch/rest-apis/highlighting-examples.md +++ b/docs/reference/elasticsearch/rest-apis/highlighting-examples.md @@ -8,7 +8,7 @@ applies_to: This page provides practical examples of how to configure highlighting in {{es}}. -# Highlighting examples [highlighting-examples] +# Highlighting examples * [Override global settings](#override-global-settings) * [Specify a highlight query](#specify-highlight-query) @@ -21,7 +21,6 @@ This page provides practical examples of how to configure highlighting in {{es}} * [Highlight using the postings list](#highlight-postings-list) * [Specify a fragmenter for the plain highlighter](#specify-fragmenter) - ## Override global settings [override-global-settings] You can specify highlighter settings globally and selectively override them for individual fields. @@ -44,7 +43,7 @@ GET /_search } } ``` - +% TEST[setup:my_index] ## Specify a highlight query [specify-highlight-query] @@ -107,7 +106,7 @@ GET /_search } } ``` - +% TEST[setup:my_index] ## Set highlighter type [set-highlighter-type] @@ -126,7 +125,7 @@ GET /_search } } ``` - +% TEST[setup:my_index] ## Configure highlighting tags [configure-tags] @@ -147,6 +146,7 @@ GET /_search } } ``` +% TEST[setup:my_index] When using the fast vector highlighter, you can specify additional tags and the "importance" is ordered. @@ -165,6 +165,7 @@ GET /_search } } ``` +% TEST[setup:my_index] You can also use the built-in `styled` tag schema: @@ -182,7 +183,7 @@ GET /_search } } ``` - +% TEST[setup:my_index] ## Highlight in all fields [highlight-all] @@ -202,7 +203,7 @@ GET /_search } } ``` - +% TEST[setup:my_index] ## Combine matches on multiple fields [matched-fields] @@ -237,6 +238,7 @@ PUT index1 } } ``` +% TEST[continued] ```console PUT index1/_bulk?refresh=true @@ -245,6 +247,7 @@ PUT index1/_bulk?refresh=true { "index" : {"_id": "doc2"} } {"comment": "running with scissors"} ``` +% TEST[continued] ```console GET index1/_search @@ -263,6 +266,7 @@ GET index1/_search } } ``` +% TEST[continued] The above request matches both "run with scissors" and "running with scissors" and would highlight "running" and "scissors" but not "run". If both phrases appear in a large document then "running with scissors" is sorted above "run with scissors" in the fragments list because there are more matches in that fragment. @@ -306,6 +310,7 @@ The above request matches both "run with scissors" and "running with scissors" a } } ``` +% TESTRESPONSE[s/\.\.\./"took" : $body.took,"timed_out" : $body.timed_out,"_shards" : $body._shards,/] The below request highlights "run" as well as "running" and "scissors", because the `matched_fields` parameter instructs that for highlighting we need to combine matches from the `comment.english` field with the matches from the original `comment` field. @@ -328,6 +333,7 @@ GET index1/_search } } ``` +% TEST[continued] ```console-result { @@ -369,6 +375,7 @@ GET index1/_search } } ``` +% TESTRESPONSE[s/\.\.\./"took" : $body.took,"timed_out" : $body.timed_out,"_shards" : $body._shards,/] :::::: ::::::{tab-item} FVH @@ -395,6 +402,7 @@ PUT index2 } } ``` +% TEST[continued] ```console PUT index2/_bulk?refresh=true @@ -403,6 +411,7 @@ PUT index2/_bulk?refresh=true { "index" : {"_id": "doc2"} } {"comment": "running with scissors"} ``` +% TEST[continued] ```console GET index2/_search @@ -423,6 +432,7 @@ GET index2/_search } } ``` +% TEST[continued] The above request matches both "run with scissors" and "running with scissors" and would highlight "running" and "scissors" but not "run". If both phrases appear in a large document then "running with scissors" is sorted above "run with scissors" in the fragments list because there are more matches in that fragment. @@ -466,6 +476,7 @@ The above request matches both "run with scissors" and "running with scissors" a } } ``` +% TESTRESPONSE[s/\.\.\./"took" : $body.took,"timed_out" : $body.timed_out,"_shards" : $body._shards,/] The below request highlights "run" as well as "running" and "scissors", because the `matched_fields` parameter instructs that for highlighting we need to combine matches from the `comment` and `comment.english` fields. @@ -489,6 +500,7 @@ GET index2/_search } } ``` +% TEST[continued] ```console-result { @@ -530,6 +542,7 @@ GET index2/_search } } ``` +% TESTRESPONSE[s/\.\.\./"took" : $body.took,"timed_out" : $body.timed_out,"_shards" : $body._shards,/] The below request wouldn’t highlight "run" or "scissor" but shows that it is just fine not to list the field to which the matches are combined (`comment.english`) in the matched fields. @@ -553,6 +566,7 @@ GET index2/_search } } ``` +% TEST[continued] ```console-result { @@ -594,6 +608,7 @@ GET index2/_search } } ``` +% TESTRESPONSE[s/\.\.\./"took" : $body.took,"timed_out" : $body.timed_out,"_shards" : $body._shards,/] :::::{note} There is a small amount of overhead involved with setting `matched_fields` to a non-empty array so always prefer @@ -605,6 +620,7 @@ There is a small amount of overhead involved with setting `matched_fields` to a } } ``` +% NOTCONSOLE to @@ -618,6 +634,7 @@ to } } ``` +% NOTCONSOLE :::::: ::::::: @@ -645,6 +662,7 @@ GET /_search } } ``` +% TEST[setup:my_index] None of the highlighters built into Elasticsearch care about the order that the fields are highlighted but a plugin might. @@ -666,6 +684,7 @@ GET /_search } } ``` +% TEST[setup:my_index] On top of this it is possible to specify that highlighted fragments need to be sorted by score: @@ -683,6 +702,7 @@ GET /_search } } ``` +% TEST[setup:my_index] If the `number_of_fragments` value is set to `0` then no fragments are produced, instead the whole content of the field is returned, and of course it is highlighted. This can be very handy if short texts (like document title or address) need to be highlighted but no fragmentation is required. Note that `fragment_size` is ignored in this case. @@ -700,6 +720,7 @@ GET /_search } } ``` +% TEST[setup:my_index] When using `fvh` one can use `fragment_offset` parameter to control the margin to start highlighting from. @@ -722,7 +743,7 @@ GET /_search } } ``` - +% TEST[setup:my_index] ## Highlight using the postings list [highlight-postings-list] @@ -781,6 +802,7 @@ GET my-index-000001/_search } } ``` +% TEST[setup:messages] Response: @@ -813,6 +835,7 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,/] ```console GET my-index-000001/_search @@ -832,6 +855,7 @@ GET my-index-000001/_search } } ``` +% TEST[setup:messages] Response: @@ -863,5 +887,6 @@ Response: } } ``` +% TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,/] If the `number_of_fragments` option is set to `0`, `NullFragmenter` is used which does not fragment the text at all. This is useful for highlighting the entire contents of a document or field. \ No newline at end of file diff --git a/docs/reference/elasticsearch/rest-apis/highlighting.md b/docs/reference/elasticsearch/rest-apis/highlighting.md index ae67f10dc6b52..a2ea3185094b3 100644 --- a/docs/reference/elasticsearch/rest-apis/highlighting.md +++ b/docs/reference/elasticsearch/rest-apis/highlighting.md @@ -32,6 +32,7 @@ GET /_search } } ``` +% TEST[setup:my_index] ## Highlighting types [highlighting-types] diff --git a/docs/reference/elasticsearch/rest-apis/how-es-highlighters-work-internally.md b/docs/reference/elasticsearch/rest-apis/how-es-highlighters-work-internally.md index e24ad5c39aae6..ebcc1c12a67a4 100644 --- a/docs/reference/elasticsearch/rest-apis/how-es-highlighters-work-internally.md +++ b/docs/reference/elasticsearch/rest-apis/how-es-highlighters-work-internally.md @@ -70,6 +70,7 @@ PUT test_index } } ``` +% NOTCONSOLE We put the following document into the index: @@ -79,6 +80,7 @@ PUT test_index/_doc/doc1 "content" : "For you I'm only a fox like a hundred thousand other foxes. But if you tame me, we'll need each other. You'll be the only boy in the world for me. I'll be the only fox in the world for you." } ``` +% NOTCONSOLE And we ran the following query with a highlight request: @@ -97,6 +99,7 @@ GET test_index/_search } } ``` +% NOTCONSOLE After `doc1` is found as a hit for this query, this hit will be passed to the unified highlighter for highlighting the field `content` of the document. Since the field `content` was not indexed either with offsets or term vectors, its raw field value will be analyzed, and in-memory index will be built from the terms that match the query: diff --git a/docs/reference/elasticsearch/rest-apis/index-disk-usage.md b/docs/reference/elasticsearch/rest-apis/index-disk-usage.md index 2cad17ebf97f8..0293fb6ec1c9c 100644 --- a/docs/reference/elasticsearch/rest-apis/index-disk-usage.md +++ b/docs/reference/elasticsearch/rest-apis/index-disk-usage.md @@ -122,7 +122,6 @@ The API returns: } } ``` - % TESTRESPONSE[s/: \{\.\.\.\}/: $body.$_path/] % TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/] % TESTRESPONSE[s/: "[^"]*"/: $body.$_path/] diff --git a/docs/reference/elasticsearch/rest-apis/optimistic-concurrency-control.md b/docs/reference/elasticsearch/rest-apis/optimistic-concurrency-control.md index ff6bf5e6ab12f..b5c6c841c1241 100644 --- a/docs/reference/elasticsearch/rest-apis/optimistic-concurrency-control.md +++ b/docs/reference/elasticsearch/rest-apis/optimistic-concurrency-control.md @@ -38,12 +38,15 @@ You can see the assigned sequence number and primary term in the `_seq_no` and ` "result": "created" } ``` +% TESTRESPONSE[s/"_seq_no": 362/"_seq_no": $body._seq_no/] +% TESTRESPONSE[s/"_primary_term": 2/"_primary_term": $body._primary_term/] Elasticsearch keeps tracks of the sequence number and primary term of the last operation to have changed each of the documents it stores. The sequence number and primary term are returned in the `_seq_no` and `_primary_term` fields in the response of the [GET API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get): ```console GET products/_doc/1567 ``` +% TEST[continued] returns: @@ -61,6 +64,8 @@ returns: } } ``` +% TESTRESPONSE[s/"_seq_no": 362/"_seq_no": $body._seq_no/] +% TESTRESPONSE[s/"_primary_term": 2/"_primary_term": $body._primary_term/] Note: The [Search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search) can return the `_seq_no` and `_primary_term` for each search hit by setting [`seq_no_primary_term` parameter](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search#request-body-search-seq-no-primary-term). @@ -76,4 +81,5 @@ PUT products/_doc/1567?if_seq_no=362&if_primary_term=2 "tags": [ "droid" ] } ``` - +% TEST[continued] +% TEST[catch: conflict] diff --git a/docs/reference/elasticsearch/rest-apis/paginate-search-results.md b/docs/reference/elasticsearch/rest-apis/paginate-search-results.md index 9fd0484ea7591..d9f7e13b991a4 100644 --- a/docs/reference/elasticsearch/rest-apis/paginate-search-results.md +++ b/docs/reference/elasticsearch/rest-apis/paginate-search-results.md @@ -38,6 +38,24 @@ You can use the `search_after` parameter to retrieve the next page of hits using Using `search_after` requires multiple search requests with the same `query` and `sort` values. The first step is to run an initial request. The following example sorts the results by two fields (`date` and `tie_breaker_id`): + + ```console GET twitter/_search { @@ -52,6 +70,7 @@ GET twitter/_search ] } ``` +% TEST[continued] 1. A copy of the `_id` field with `doc_values` enabled @@ -92,6 +111,7 @@ The search response includes an array of `sort` values for each hit: } } ``` +% TESTRESPONSE[skip: demo of where the sort values are] 1. Sort values for the last returned hit. @@ -113,12 +133,14 @@ GET twitter/_search ] } ``` +% TEST[continued] Repeat this process by updating the `search_after` array every time you retrieve a new page of results. If a [refresh](docs-content://manage-data/data-store/near-real-time-search.md) occurs between these requests, the order of your results may change, causing inconsistent results across pages. To prevent this, you can create a [point in time (PIT)](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-open-point-in-time) to preserve the current index state over your searches. ```console POST /my-index-000001/_pit?keep_alive=1m ``` +% TEST[setup:my_index] The API returns a PIT ID. @@ -128,6 +150,8 @@ The API returns a PIT ID. "_shards": ... } ``` +% TESTRESPONSE[s/"id": "46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA=="/"id": $body.id/] +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": "$body._shards"/] To get the first page of results, submit a search request with a `sort` argument. If using a PIT, specify the PIT ID in the `pit.id` parameter and omit the target data stream or index from the request path. @@ -164,6 +188,7 @@ GET /_search ] } ``` +% TEST[catch:unavailable] 1. PIT ID for the search. 2. Sorts hits for the search with an implicit tiebreak on `_shard_doc` ascending. @@ -190,6 +215,7 @@ GET /_search ] } ``` +% TEST[catch:unavailable] 1. PIT ID for the search. 2. Sorts hits for the search with an explicit tiebreak on `_shard_doc` descending. @@ -220,6 +246,7 @@ GET /_search } } ``` +% TESTRESPONSE[skip: unable to access PIT ID] 1. Updated `id` for the point in time. 2. Sort values for the last returned hit. @@ -251,6 +278,7 @@ GET /_search "track_total_hits": false <3> } ``` +% TEST[catch:unavailable] 1. PIT ID returned by the previous search. 2. Sort values from the previous search’s last hit. @@ -267,7 +295,7 @@ DELETE /_pit "id" : "46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==" } ``` - +% TEST[catch:missing] ## Scroll search results [scroll-search-results] @@ -313,6 +341,7 @@ POST /my-index-000001/_search?scroll=1m } } ``` +% TEST[setup:my_index] The result from the above request includes a `_scroll_id`, which should be passed to the `scroll` API in order to retrieve the next batch of results. @@ -323,6 +352,7 @@ POST /_search/scroll "scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==" <3> } ``` +% TEST[continued s/DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==/$body._scroll_id/] 1. `GET` or `POST` can be used and the URL should not include the `index` name — this is specified in the original `search` request instead. 2. The `scroll` parameter tells Elasticsearch to keep the search context open for another `1m`. @@ -354,6 +384,7 @@ GET /_search?scroll=1m ] } ``` +% TEST[setup:my_index] ### Keeping the search context alive [scroll-search-context] @@ -393,6 +424,7 @@ DELETE /_search/scroll "scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==" } ``` +% TEST[catch:missing] Multiple scroll IDs can be passed as array: @@ -405,6 +437,7 @@ DELETE /_search/scroll ] } ``` +% TEST[catch:missing] All search contexts can be cleared with the `_all` parameter: @@ -417,7 +450,7 @@ The `scroll_id` can also be passed as a query string parameter or in the request ```console DELETE /_search/scroll/DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==,DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAABFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAAAxZrUllkUVlCa1NqNmRMaUhiQlZkMWFBAAAAAAAAAAIWa1JZZFFZQmtTajZkTGlIYkJWZDFhQQAAAAAAAAAFFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAABBZrUllkUVlCa1NqNmRMaUhiQlZkMWFB ``` - +% TEST[catch:missing] ### Sliced scroll [slice-scroll] @@ -449,6 +482,7 @@ GET /my-index-000001/_search?scroll=1m } } ``` +% TEST[setup:my_index_big] 1. The id of the slice 2. The maximum number of slices @@ -488,6 +522,7 @@ GET /my-index-000001/_search?scroll=1m } } ``` +% TEST[setup:my_index_big] For append only time-based indices, the `timestamp` field can be used safely. diff --git a/docs/reference/elasticsearch/rest-apis/query-api-keys.md b/docs/reference/elasticsearch/rest-apis/query-api-keys.md index cbf28e543a8a4..57a578d1c9198 100644 --- a/docs/reference/elasticsearch/rest-apis/query-api-keys.md +++ b/docs/reference/elasticsearch/rest-apis/query-api-keys.md @@ -212,10 +212,12 @@ POST /_security/api_key A successful call returns a JSON structure that provides API key information. For example: ```console-result +{ "id": "VuaCfGcBCdbkQm-e5aOx", "name": "application-key-1", "api_key": "ui2lp2axTNmsyakw9tvNnw", "encoded": "VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==" +} ``` % TESTRESPONSE[s/VuaCfGcBCdbkQm-e5aOx/$body.id/] % TESTRESPONSE[s/ui2lp2axTNmsyakw9tvNnw/$body.api_key/] diff --git a/docs/reference/elasticsearch/rest-apis/reciprocal-rank-fusion.md b/docs/reference/elasticsearch/rest-apis/reciprocal-rank-fusion.md index 6e22e2504bb68..a337a5fd8d7e3 100644 --- a/docs/reference/elasticsearch/rest-apis/reciprocal-rank-fusion.md +++ b/docs/reference/elasticsearch/rest-apis/reciprocal-rank-fusion.md @@ -25,6 +25,7 @@ return score # result(q) is the result set of q # rank( result(q), d ) is d's rank within the result(q) starting from 1 ``` +% NOTCONSOLE ## Reciprocal rank fusion API [rrf-api] @@ -88,6 +89,7 @@ GET example-index/_search } } ``` +% TEST[skip:example fragment] In the above example, we execute the `knn` and `standard` retrievers independently of each other. Then we use the `rrf` retriever to combine the results. @@ -163,6 +165,7 @@ GET example-index/_search } } ``` +% TEST[skip:example fragment] In the above example, we execute each of the two `standard` retrievers independently of each other. Then we use the `rrf` retriever to combine the results. @@ -242,6 +245,7 @@ PUT example-index/_doc/5 POST example-index/_refresh ``` +% TEST We now execute a search using an `rrf` retriever with a `standard` retriever specifying a BM25 query, a `knn` retriever specifying a kNN search, and a terms aggregation. @@ -283,6 +287,7 @@ GET example-index/_search } } ``` +% TEST[continued] And we receive the response with ranked `hits` and the terms aggregation result. We have both the ranker’s `score` and the `_rank` option to show our top-ranked documents. @@ -356,6 +361,7 @@ And we receive the response with ranked `hits` and the terms aggregation result. } } ``` +% TESTRESPONSE[s/: \.\.\./: $body.$_path/] Let’s break down how these hits were ranked. We start by running the `standard` retriever specifying a query and the `knn` retriever specifying a kNN search separately to collect what their individual hits are. @@ -404,6 +410,7 @@ First, we look at the hits for the query from the `standard` retriever. } ] ``` +% TEST[skip:example fragment] 1. rank 1, `_id` 4 2. rank 2, `_id` 3 @@ -456,6 +463,7 @@ Note that our first hit doesn’t have a value for the `vector` field. Now, we l } ] ``` +% TEST[skip:example fragment] 1. rank 1, `_id` 3 2. rank 2, `_id` 2 @@ -473,6 +481,7 @@ _id: 3 = 1.0/(1+2) + 1.0/(1+1) = 0.8333 _id: 4 = 1.0/(1+1) = 0.5000 _id: 5 = 1.0/(1+4) = 0.2000 ``` +% NOTCONSOLE We rank the documents based on the RRF formula with a `rank_window_size` of `5` truncating the bottom `2` docs in our RRF result set with a `size` of `3`. We end with `_id: 3` as `_rank: 1`, `_id: 2` as `_rank: 2`, and `_id: 4` as `_rank: 3`. This ranking matches the result set from the original RRF search as expected. @@ -530,6 +539,7 @@ In addition to individual query scoring details, we can make use of the `explain ] } ``` +% NOTCONSOLE 1. the final RRF score for document with `_id=3` 2. a description on how this score was computed based on the ranks of this document in each individual query @@ -580,6 +590,7 @@ GET example-index/_search } } ``` +% NOTCONSOLE 1. Here we specify a `_name` for the `knn` retriever @@ -623,6 +634,7 @@ The response would now include the named query in the explanation: ] } ``` +% NOTCONSOLE 1. Instead of the anonymous `at index n` , we now have a reference to the named query `my_knn_query`. @@ -647,6 +659,7 @@ _id: | 3 | 3 | _id: | 4 | 1 | _id: | | 2 | ``` +% NOTCONSOLE For `rank_window_size=5` we would get to see all documents from both `queryA` and `queryB`. Assuming a `rank_constant=1`, the `rrf` scores would be: @@ -658,6 +671,7 @@ _id: 3 = 1.0/(1+3) + 1.0/(1+3) = 0.5 _id: 4 = 1.0/(1+4) + 1.0/(1+2) = 0.533 _id: 5 = 0 + 1.0/(1+1) = 0.5 ``` +% NOTCONSOLE So the final ranked result set would be [`1`, `4`, `2`, `3`, `5`] and we would paginate over that, since `rank_window_size == len(results)`. In this scenario, we would have: @@ -675,6 +689,7 @@ _id: 2 = 1.0/(1+2) + 0 = 0.33 _id: 4 = 0 + 1.0/(1+2) = 0.33 _id: 5 = 0 + 1.0/(1+1) = 0.5 ``` +% NOTCONSOLE The final ranked result set would be [`1`, `5`, `2`, `4`], and we would be able to paginate on the top `rank_window_size` results, i.e. [`1`, `5`]. So for the same params as above, we would now have: @@ -700,6 +715,7 @@ For example, consider the following document set: "_id": 4, "termA": "foo", "termB": "bar" } ``` +% NOTCONSOLE Perform a term aggregation on the `termA` field using an `rrf` retriever: @@ -738,6 +754,7 @@ Perform a term aggregation on the `termA` field using an `rrf` retriever: } } ``` +% NOTCONSOLE The aggregation results will include **all** matching documents, regardless of `rank_window_size`. @@ -747,7 +764,7 @@ The aggregation results will include **all** matching documents, regardless of ` "aardvark": 1 } ``` - +% NOTCONSOLE ## Highlighting in RRF [_highlighting_in_rrf] diff --git a/docs/reference/elasticsearch/rest-apis/reindex-data-stream.md b/docs/reference/elasticsearch/rest-apis/reindex-data-stream.md index ee6bb0598a8f9..51d202bb8af37 100644 --- a/docs/reference/elasticsearch/rest-apis/reindex-data-stream.md +++ b/docs/reference/elasticsearch/rest-apis/reindex-data-stream.md @@ -26,6 +26,15 @@ The reindex data stream API is used to upgrade the backing indices of a data str This api runs in the background because reindexing all indices in a large data stream is expected to take a large amount of time and resources. The endpoint will return immediately and a persistent task will be created to run in the background. The current status of the task can be checked with the [reindex status API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-migrate-reindex-status). This status will be available for 24 hours after the task completes, whether it finished successfully or failed. If the status is still available for a task, the task must be cancelled before it can be re-run. A running or recently completed data stream reindex task can be cancelled using the [reindex cancel API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-cancel-migrate-reindex). + + ## {{api-request-title}} [data-stream-reindex-api-request] `POST /_migration/reindex` @@ -81,6 +90,7 @@ POST _migration/reindex "mode": "upgrade" } ``` +% TEST[setup:my_data_stream] As this task runs in the background this API will return immediately. The task will do the following. @@ -104,6 +114,7 @@ While the reindex data stream task is running, we can inspect the current status ```console GET /_migration/reindex/my-data-stream/_status ``` +% TEST[continued] For the above example, the following would be a possible status: @@ -125,6 +136,7 @@ For the above example, the following would be a possible status: "errors": [] } ``` +% TEST[skip:specific value is part of explanation] This output means that the first backing index, `.ds-my-data-stream-2025.01.23-000001`, is currently being processed, and none of the backing indices have yet completed. Notice that `total_indices_in_data_stream` has a value of `4`, because after the rollover, there are 4 indices in the data stream. But the new write index has an 8.x version, and thus doesn’t need to be reindexed, so `total_indices_requiring_upgrade` is only 3. @@ -152,6 +164,7 @@ Continuing with the above example, assume the reindexing task has not yet comple "errors": [] } ``` +% TEST[skip:specific value is part of explanation] Let’s assume the task has been running for a long time. By default, we throttle how many requests the reindex operation can execute per second. This keeps the reindex process from consuming too many resources. But the default value of `1000` request per second will not be correct for all use cases. The [`migrate.data_stream_reindex_max_request_per_second` setting](#migrate_data_stream_reindex_max_request_per_second-setting) can be used to increase or decrease the number of requests per second, or to remove the throttle entirely. @@ -162,6 +175,7 @@ But in the above status, `.ds-my-data-stream-2025.01.23-000002` has values of 10 ```console POST /_migration/reindex/my-data-stream/_cancel ``` +% TEST[skip:task will not be present] Now we can use the [update cluster settings API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings) to increase the throttle: @@ -173,6 +187,7 @@ PUT /_cluster/settings } } ``` +% TEST[continued] The [original reindex command](#reindex-data-stream-start) can now be used to restart reindexing. Because the first backing index, `.ds-my-data-stream-2025.01.23-000001`, has already been reindexed and thus is already version 8.x, it will be skipped. The task will start by reindexing `.ds-my-data-stream-2025.01.23-000002` again from the beginning. @@ -190,6 +205,7 @@ Later, once all the backing indices have finished, the [reindex status API](http "errors": [] } ``` +% TEST[skip:specific value is part of explanation] Notice that the value of `total_indices_requiring_upgrade` is `2`, unlike the previous status, which had a value of `3`. This is because `.ds-my-data-stream-2025.01.23-000001` was upgraded before the task cancellation. After the restart, the API sees that it does not need to be upgraded, thus does not include it in `total_indices_requiring_upgrade` or `successes`, despite the fact that it upgraded successfully. @@ -200,6 +216,7 @@ We can now check the data stream to verify that indices were upgraded: ```console GET _data_stream/my-data-stream?filter_path=data_streams.indices.index_name ``` +% TEST[continued] which returns: @@ -225,6 +242,7 @@ which returns: ] } ``` +% TEST[skip:did not actually run reindex] Index `.ds-my-data-stream-2025.01.23-000004` is the write index and didn’t need to be upgraded because it was created with version 8.x. The other three backing indices are now prefixed with `.migrated` because they have been upgraded. @@ -233,6 +251,7 @@ We can now check the indices and verify that they have version 8.x: ```console GET .migrated-ds-my-data-stream-2025.01.23-000001?human&filter_path=*.settings.index.version.created_string ``` +% TEST[skip:migrated index does not exist] which returns: @@ -249,7 +268,7 @@ which returns: } } ``` - +% TEST[skip:migrated index does not exist] ### Handling Failures [reindex-data-stream-handling-failure] @@ -272,5 +291,6 @@ Since the reindex data stream API runs in the background, failure information ca ] } ``` +% TEST[skip:result just part of explanation] Once the issue has been fixed, the failed reindex task can be re-run. First, the failed run’s status must be cleared using the [reindex cancel API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-cancel-migrate-reindex). Then the [original reindex command](#reindex-data-stream-start) can be called to pick up where it left off. diff --git a/docs/reference/elasticsearch/rest-apis/reindex-indices.md b/docs/reference/elasticsearch/rest-apis/reindex-indices.md index 84e3d432f61ef..9e2b8dccf60af 100644 --- a/docs/reference/elasticsearch/rest-apis/reindex-indices.md +++ b/docs/reference/elasticsearch/rest-apis/reindex-indices.md @@ -597,7 +597,7 @@ POST _reindex { "source": { "remote": { - "host": "<OTHER_HOST_URL>", + "host": "", "username": "user", "password": "pass" }, @@ -615,7 +615,7 @@ POST _reindex ``` % TEST[setup:host] % TEST[s/^/PUT my-index-000001\n/] -% TEST[s/otherhost:9200",/\${host}",/] +% TEST[s/"host": [^}]*,/"host": "http:\/\/\${host}",/] % TEST[s/"username": "user",/"username": "test_admin",/] % TEST[s/"password": "pass"/"password": "x-pack-test-password"/] @@ -638,8 +638,8 @@ POST _reindex { "source": { "remote": { - "host": "<OTHER_HOST_URL>", - "api_key": "<API_KEY_VALUE>" + "host": "", + "api_key": "" }, "index": "my-index-000001", "query": { @@ -655,7 +655,7 @@ POST _reindex ``` % TEST[setup:host] % TEST[s/^/PUT my-index-000001\n/] -% TEST[s/otherhost:9200",/\${host}",/] +% TEST[s/"host": [^}]*,/"host": "http:\/\/\${host}",/] % TEST[s/"headers": \{[^}]*\}/"username": "test_admin", "password": "x-pack-test-password"/] ::: @@ -665,9 +665,9 @@ POST _reindex { "source": { "remote": { - "host": "<OTHER_HOST_URL>", + "host": "", "headers": { - "Authorization": "ApiKey <API_KEY_VALUE>" + "Authorization": "" } }, "index": "my-index-000001", @@ -684,7 +684,7 @@ POST _reindex ``` % TEST[setup:host] % TEST[s/^/PUT my-index-000001\n/] -% TEST[s/otherhost:9200",/\${host}",/] +% TEST[s/"host": [^}]*,/"host": "http:\/\/\${host}",/] % TEST[s/"headers": \{[^}]*\}/"username": "test_admin", "password": "x-pack-test-password"/] ::: @@ -727,7 +727,7 @@ POST _reindex { "source": { "remote": { - "host": "<OTHER_HOST_URL>", + "host": "", ... }, "index": "source", @@ -745,7 +745,7 @@ POST _reindex ``` % TEST[setup:host] % TEST[s/^/PUT source\n/] -% TEST[s/otherhost:9200/\${host}/] +% TEST[s/"host": [^}]*,/"host": "http:\/\/\${host}",/] % TEST[s/\.\.\./"username": "test_admin", "password": "x-pack-test-password"/] It is also possible to set the socket read timeout on the remote connection with the `socket_timeout` field and the connection timeout with the `connect_timeout` field. @@ -757,7 +757,7 @@ POST _reindex { "source": { "remote": { - "host": "<OTHER_HOST_URL>", + "host": "", ..., "socket_timeout": "1m", "connect_timeout": "10s" @@ -776,7 +776,7 @@ POST _reindex ``` % TEST[setup:host] % TEST[s/^/PUT source\n/] -% TEST[s/otherhost:9200/\${host}/] +% TEST[s/"host": [^}]*,/"host": "http:\/\/\${host}",/] % TEST[s/\.\.\.,/"username": "test_admin", "password": "x-pack-test-password",/] ### Configuring SSL parameters [reindex-ssl] diff --git a/docs/reference/elasticsearch/rest-apis/retrieve-inner-hits.md b/docs/reference/elasticsearch/rest-apis/retrieve-inner-hits.md index 62c521840f5f3..e966ba7a10229 100644 --- a/docs/reference/elasticsearch/rest-apis/retrieve-inner-hits.md +++ b/docs/reference/elasticsearch/rest-apis/retrieve-inner-hits.md @@ -20,6 +20,7 @@ Inner hits can be used by defining an `inner_hits` definition on a `nested`, `ha } } ``` +% NOTCONSOLE If `inner_hits` is defined on a query that supports it then each search hit will contain an `inner_hits` json object with the following structure: @@ -48,7 +49,7 @@ If `inner_hits` is defined on a query that supports it then each search hit will ... ] ``` - +% NOTCONSOLE ## Options [inner-hits-options] @@ -174,6 +175,8 @@ An example of a response snippet that could be generated from the above search r } } ``` +% TESTRESPONSE[s/"_source": \.\.\./"_source": $body.hits.hits.0._source/] +% TESTRESPONSE[s/\.\.\./"timed_out": false, "took": $body.took, "_shards": $body._shards/] 1. The name used in the inner hit definition in the search request. A custom key can be used via the `name` option. @@ -235,6 +238,58 @@ POST test/_search } ``` + ## Hierarchical levels of nested object fields and inner hits. [hierarchical-nested-inner-hits] @@ -345,6 +400,8 @@ Which would look like: } } ``` +% TESTRESPONSE[s/"_source": \.\.\./"_source": $body.hits.hits.0._source/] +% TESTRESPONSE[s/\.\.\./"timed_out": false, "took": $body.took, "_shards": $body._shards/] This indirect referencing is only supported for nested inner hits. @@ -453,4 +510,5 @@ An example of a response snippet that could be generated from the above search r } } ``` - +% TESTRESPONSE[s/"_source": \.\.\./"_source": $body.hits.hits.0._source/] +% TESTRESPONSE[s/\.\.\./"timed_out": false, "took": $body.took, "_shards": $body._shards/] diff --git a/docs/reference/elasticsearch/rest-apis/retrieve-selected-fields.md b/docs/reference/elasticsearch/rest-apis/retrieve-selected-fields.md index 7a755b76c7540..d3cb812296991 100644 --- a/docs/reference/elasticsearch/rest-apis/retrieve-selected-fields.md +++ b/docs/reference/elasticsearch/rest-apis/retrieve-selected-fields.md @@ -58,6 +58,8 @@ POST my-index-000001/_search "_source": false } ``` +% TEST[setup:my_index] +% TEST[s/_search/_search\?filter_path=hits/] 1. Both full field names and wildcard patterns are accepted. 2. Use the `format` parameter to apply a custom format for the field’s values. @@ -107,7 +109,8 @@ The response includes values as a flat list in the `fields` section for each hit } } ``` - +% TESTRESPONSE[s/"max_score" : 1.0/"max_score" : $body.hits.max_score/] +% TESTRESPONSE[s/"_score" : 1.0/"_score" : $body.hits.hits.0._score/] ### Retrieve nested fields [search-fields-nested] @@ -193,6 +196,9 @@ The response will group `first` and `last` name instead of returning them as a f } } ``` +% TESTRESPONSE[s/"took": 2/"took": $body.took/] +% TESTRESPONSE[s/"max_score" : 1.0/"max_score" : $body.hits.max_score/] +% TESTRESPONSE[s/"_score" : 1.0/"_score" : $body.hits.hits.0._score/] Nested fields will be grouped by their nested paths, no matter the pattern used to retrieve them. For example, if you query only for the `user.first` field from the previous example: @@ -203,6 +209,7 @@ POST my-index-000001/_search "_source": false } ``` +% TEST[continued] The response returns only the user’s first name, but still maintains the structure of the nested `user` array: @@ -239,6 +246,9 @@ The response returns only the user’s first name, but still maintains the struc } } ``` +% TESTRESPONSE[s/"took": 2/"took": $body.took/] +% TESTRESPONSE[s/"max_score" : 1.0/"max_score" : $body.hits.max_score/] +% TESTRESPONSE[s/"_score" : 1.0/"_score" : $body.hits.hits.0._score/] However, when the `fields` pattern targets the nested `user` field directly, no values will be returned because the pattern doesn’t match any leaf fields. @@ -321,6 +331,9 @@ The response will contain field results under the `session_data.object.*` path, } } ``` +% TESTRESPONSE[s/"took" : 2/"took": $body.took/] +% TESTRESPONSE[s/"max_score" : 1.0/"max_score" : $body.hits.max_score/] +% TESTRESPONSE[s/"_score" : 1.0/"_score" : $body.hits.hits.0._score/] :::: @@ -403,6 +416,9 @@ The response will contain ignored field values under the `ignored_field_values` } } ``` +% TESTRESPONSE[s/"took" : 2/"took": $body.took/] +% TESTRESPONSE[s/"max_score" : 1.0/"max_score" : $body.hits.max_score/] +% TESTRESPONSE[s/"_score" : 1.0/"_score" : $body.hits.hits.0._score/] :::: @@ -522,6 +538,7 @@ GET my-index-000001/_search ] } ``` +% TEST[setup:my_index] 1. Both full field names and wildcard patterns are accepted. 2. Using object notation, you can pass a `format` parameter to apply a custom format for the field’s doc values. [Date fields](/reference/elasticsearch/mapping-reference/date.md) support a [date `format`](/reference/elasticsearch/mapping-reference/mapping-date-format.md). [Numeric fields](/reference/elasticsearch/mapping-reference/number.md) support a [DecimalFormat pattern](https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.md). Other field datatypes do not support the `format` parameter. @@ -630,6 +647,7 @@ GET /_search } } ``` +% TEST[setup:sales] Script fields can work on fields that are not stored (`price` in the above case), and allow to return custom values to be returned (the evaluated value of the script). @@ -648,6 +666,7 @@ GET /_search } } ``` +% TEST[setup:my_index] Note the `_source` keyword here to navigate the json-like model. diff --git a/docs/reference/elasticsearch/rest-apis/retrieve-stored-fields.md b/docs/reference/elasticsearch/rest-apis/retrieve-stored-fields.md index 319093c8bb923..34fb91c531b95 100644 --- a/docs/reference/elasticsearch/rest-apis/retrieve-stored-fields.md +++ b/docs/reference/elasticsearch/rest-apis/retrieve-stored-fields.md @@ -43,7 +43,6 @@ PUT my-index-000001/_doc/1 "tags": [ "production" ] } ``` - % TEST[continued] This request retrieves the stored fields from the document: @@ -51,7 +50,6 @@ This request retrieves the stored fields from the document: ```console GET my-index-000001/_doc/1?stored_fields=tags,counter ``` - % TEST[continued] The API returns the following response: @@ -61,7 +59,7 @@ The API returns the following response: "_index": "my-index-000001", "_id": "1", "_version": 1, - "_seq_no": 22, + "_seq_no": 0, "_primary_term": 1, "found": true, "fields": { @@ -71,7 +69,6 @@ The API returns the following response: } } ``` - % TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] Although the `counter` field is specified in the request, it's not included in the response because it's not actually a stored field. diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/knn-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/knn-retriever.md index 8133b631ae807..20ab33cb82de6 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/knn-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/knn-retriever.md @@ -94,6 +94,83 @@ The parameters `query_vector` and `query_vector_builder` cannot be used together ## Example [knn-retriever-example] + + ```console GET /restaurants/_search { diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/linear-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/linear-retriever.md index cd62423e196f8..296c8f311a85a 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/linear-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/linear-retriever.md @@ -115,7 +115,7 @@ GET my_index/_search "num_candidates": 100 } }, - "weight": 5 # KNN query weighted 5x + "weight": 5 <1> }, { "retriever": { @@ -127,7 +127,7 @@ GET my_index/_search } } }, - "weight": 1.5 # BM25 query weighted 1.5x + "weight": 1.5 <2> } ], "normalizer": "minmax" @@ -135,6 +135,8 @@ GET my_index/_search } } ``` +1. KNN query weighted 5x +2. BM25 query weighted 1.5x In this example, the `minmax` normalizer is applied to both the kNN retriever and the standard retriever. The top-level normalizer serves as a default that can be overridden by individual sub-retrievers. When using the multi-field query format, the top-level normalizer is applied to all generated inner retrievers. diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/pinned-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/pinned-retriever.md index 572fae25b333f..0be4ec08f8494 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/pinned-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/pinned-retriever.md @@ -31,6 +31,83 @@ Either `ids` or `docs` must be specified. ## Example using `docs` [pinned-retriever-example-documents] + + ```console GET /restaurants/_search { diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/rescorer-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/rescorer-retriever.md index 3770fd2121678..d6a5393b051e1 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/rescorer-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/rescorer-retriever.md @@ -46,6 +46,83 @@ When using the `rescorer`, an error is returned if the following conditions are The `rescorer` retriever can be placed at any level within the retriever tree. The following example demonstrates a `rescorer` applied to the results produced by an `rrf` retriever: + + ```console GET movies/_search { @@ -113,6 +190,7 @@ GET movies/_search } } ``` +% TEST[skip:uses ELSER] 1. Specifies the number of top documents to return in the final response. 2. A `rescorer` retriever applied as the final step. diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/rrf-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/rrf-retriever.md index 622f8881cf84f..55dfbe528e41a 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/rrf-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/rrf-retriever.md @@ -57,6 +57,83 @@ Combining `query` and `retrievers` is not supported. A simple hybrid search example (lexical search + dense vector search) combining a `standard` retriever with a `knn` retriever using RRF: + + ```console GET /restaurants/_search { @@ -91,6 +168,7 @@ GET /restaurants/_search } } ``` +% TEST[continued] 1. Defines a retriever tree with an RRF retriever. 2. The sub-retriever array. @@ -146,4 +224,4 @@ GET movies/_search } } ``` - +% TEST[skip:uses ELSER] diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/rule-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/rule-retriever.md index e9bd4ac78d2cc..c0b97a15d707d 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/rule-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/rule-retriever.md @@ -41,6 +41,84 @@ To use the `rule` retriever you must first create one or more query rulesets usi This example shows the rule retriever executed without any additional retrievers. It runs the query defined by the `retriever` and applies the rules from `my-ruleset` on top of the returned results. + + ```console GET movies/_search { @@ -65,6 +143,7 @@ GET movies/_search } } ``` +% TEST[skip:uses ELSER] ## Example: Rule retriever combined with RRF [rule-retriever-example-rrf] @@ -115,6 +194,7 @@ GET movies/_search } } ``` +% TEST[skip:uses ELSER] 1. The `rule` retriever is the outermost retriever, applying rules to the search results that were previously reranked using the `rrf` retriever. 2. The `rrf` retriever returns results from all of its sub-retrievers, and the output of the `rrf` retriever is used as input to the `rule` retriever. diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/standard-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/standard-retriever.md index e4c6e4b7554da..7f88e408adee3 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/standard-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/standard-retriever.md @@ -56,6 +56,82 @@ A standard retriever returns top documents from a traditional [query](/reference When a retriever tree contains a compound retriever (a retriever with two or more child retrievers) the [search after](/reference/elasticsearch/rest-apis/paginate-search-results.md#search-after) parameter is not supported. + ## Example [standard-retriever-example] @@ -86,6 +162,7 @@ GET /restaurants/_search } } ``` +% TEST[continued] 1. Opens the `retriever` object. 2. The `standard` retriever is used for defining traditional {{es}} queries. diff --git a/docs/reference/elasticsearch/rest-apis/retrievers/text-similarity-reranker-retriever.md b/docs/reference/elasticsearch/rest-apis/retrievers/text-similarity-reranker-retriever.md index 1ffa71608e849..5c9f8cb777049 100644 --- a/docs/reference/elasticsearch/rest-apis/retrievers/text-similarity-reranker-retriever.md +++ b/docs/reference/elasticsearch/rest-apis/retrievers/text-similarity-reranker-retriever.md @@ -136,6 +136,7 @@ Follow these steps: } } ``` + % TEST[skip:uses ML] 1. [Adaptive allocations](docs-content://deploy-manage/autoscaling/trained-model-autoscaling.md#enabling-autoscaling-through-apis-adaptive-allocations) will be enabled with the minimum of 1 and the maximum of 10 allocations. @@ -164,6 +165,7 @@ Follow these steps: } } ``` + % TEST[skip:uses ML] @@ -194,6 +196,7 @@ GET /index/_search } } ``` +% TEST[skip:uses ML] ## Example: Semantic re-ranking with a Hugging Face model [text-similarity-reranker-retriever-example-eland] @@ -239,7 +242,8 @@ Follow these steps to load the model and create a semantic re-ranker. } } ``` - + % TEST[skip:uses ELSER] + 4. Define a `text_similarity_rerank` retriever. ```console @@ -263,5 +267,6 @@ Follow these steps to load the model and create a semantic re-ranker. } } ``` + % TEST[skip:uses ELSER] This retriever uses a standard `match` query to search the `movie` index for films tagged with the genre "drama". It then re-ranks the results based on semantic similarity to the text in the `inference_text` parameter, using the model we uploaded to {{es}}. diff --git a/docs/reference/elasticsearch/rest-apis/search-multiple-data-streams-indices.md b/docs/reference/elasticsearch/rest-apis/search-multiple-data-streams-indices.md index 0c8f799efd91c..46416f3ad07c6 100644 --- a/docs/reference/elasticsearch/rest-apis/search-multiple-data-streams-indices.md +++ b/docs/reference/elasticsearch/rest-apis/search-multiple-data-streams-indices.md @@ -26,6 +26,8 @@ GET /my-index-000001,my-index-000002/_search } } ``` +% TEST[setup:my_index] +% TEST[s/^/PUT my-index-000002\n/] You can also search multiple data streams and indices using an index pattern. @@ -41,6 +43,7 @@ GET /my-index-*/_search } } ``` +% TEST[setup:my_index] You can exclude specific indices from a search. The request will retrieve data from all indices starting with `my-index-`, except for `my-index-01`. @@ -67,6 +70,7 @@ GET /my-index-*/_search } } ``` +% TEST[setup:my_index] To search all data streams and indices in a cluster, omit the target from the request path. Alternatively, you can use `_all` or `*`. @@ -100,7 +104,7 @@ GET /*/_search } } ``` - +% TEST[setup:my_index] ## Index boost [index-boost] @@ -120,6 +124,7 @@ GET /_search ] } ``` +% TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/] Aliases and index patterns can also be used: @@ -132,6 +137,7 @@ GET /_search ] } ``` +% TEST[s/^/PUT my-index-000001\nPUT my-index-000001\/_alias\/my-alias\n/] If multiple matches are found, the first match will be used. For example, if an index is included in `alias1` and matches the `my-index*` pattern, a boost value of `1.4` is applied. diff --git a/docs/reference/elasticsearch/rest-apis/search-profile.md b/docs/reference/elasticsearch/rest-apis/search-profile.md index 242600cb2ec06..76e57c9c7de30 100644 --- a/docs/reference/elasticsearch/rest-apis/search-profile.md +++ b/docs/reference/elasticsearch/rest-apis/search-profile.md @@ -33,6 +33,7 @@ GET /my-index-000001/_search } } ``` +% TEST[setup:my_index] 1. Setting the top-level `profile` parameter to `true` will enable profiling for the search. @@ -229,6 +230,11 @@ The API returns the following result: } } ``` +% TESTRESPONSE[s/"took": 25/"took": $body.took/] +% TESTRESPONSE[s/"hits": \[...\]/"hits": $body.$_path/] +% TESTRESPONSE[s/(?<=[" ])\d+(\.\d+)?/$body.$_path/] +% TESTRESPONSE[s/"id": "\[q2aE02wS1R8qQFnYu6vDVQ\]\[my-index-000001\]\[0\]"/"id": $body.profile.shards.0.id/] +% TESTRESPONSE[s/"node_id": "q2aE02wS1R8qQFnYu6vDVQ",/"node_id": "$body.profile.shards.0.node_id",/] 1. Search results are returned, but were omitted here for brevity. @@ -261,6 +267,14 @@ The overall structure of the profile response is as follows: } } ``` +% TESTRESPONSE[s/"profile": /"took": $body.took, "timed_out": $body.timed_out, "_shards": $body._shards, "hits": $body.hits, "profile": /] +% TESTRESPONSE[s/(?>=[" ])\d+(\.\d+)?/$body.$_path/] +% TESTRESPONSE[s/"id": "\[q2aE02wS1R8qQFnYu6vDVQ\]\[my-index-000001\]\[0\]"/"id": $body.profile.shards.0.id/] +% TESTRESPONSE[s/"node_id": "q2aE02wS1R8qQFnYu6vDVQ",/"node_id": "$body.profile.shards.0.node_id",/] +% TESTRESPONSE[s/"query": \[…​\]/"query": $body.$_path/] +% TESTRESPONSE[s/"collector": \[…​\]/"collector": $body.$_path/] +% TESTRESPONSE[s/"aggregations": \[…​\]/"aggregations": []/] +% TESTRESPONSE[s/"fetch": \{…​\}/"fetch": $body.$_path/] 1. A profile is returned for each shard that participated in the response, and is identified by a unique ID. 2. If the query was run on the local cluster, the cluster name is left out of the composite id and is marked "(local)" here. For a profile running on a remote_cluster using cross-cluster search, the "id" value would be something like `[q2aE02wS1R8qQFnYu6vDVQ][remote1:my-index-000001][0]` and the "cluster" value would be `remote1`. @@ -321,6 +335,10 @@ The `query` section contains detailed timing of the query tree executed by Lucen } ] ``` +% TESTRESPONSE[s/^/{\n"took": $body.took,\n"timed_out": $body.timed_out,\n"_shards": $body._shards,\n"hits": $body.hits,\n"profile": {\n"shards": [ {\n"id": "$body.profile.shards.0.id",\n"node_id": "$body.profile.shards.0.node_id",\n"shard_id": $body.profile.shards.0.shard_id,\n"index": "$body.profile.shards.0.index",\n"cluster": "(local)",\n"searches": [{\n/] +% TESTRESPONSE[s/]$/],"rewrite_time": $body.$_path, "collector": $body.$_path}], "aggregations": [], "fetch": $body.$_path}]}}/] +% TESTRESPONSE[s/(?>=[" ])\d+(\.\d+)?/$body.$_path/] +% TESTRESPONSE[s/"breakdown": \{…​\}/"breakdown": $body.$_path/] 1. The breakdown timings are omitted for simplicity. @@ -360,6 +378,9 @@ The `breakdown` component lists detailed timing statistics about low-level Lucen "count_weight_count": 0 } ``` +% TESTRESPONSE[s/^/{\n"took": $body.took,\n"timed_out": $body.timed_out,\n"_shards": $body._shards,\n"hits": $body.hits,\n"profile": {\n"shards": [ {\n"id": "$body.profile.shards.0.id",\n"node_id": "$body.profile.shards.0.node_id",\n"shard_id": $body.profile.shards.0.shard_id,\n"index": "$body.profile.shards.0.index",\n"cluster": "(local)",\n"searches": [{\n"query": [{\n"type": "BooleanQuery",\n"description": "message:get message:search",\n"time_in_nanos": $body.$_path,/] +% TESTRESPONSE[s/}$/},\n"children": $body.$_path}],\n"rewrite_time": $body.$_path, "collector": $body.$_path}], "aggregations": [], "fetch": $body.$_path}]}}/] +% TESTRESPONSE[s/(?>=[" ])\d+(\.\d+)?/$body.$_path/] Timings are listed in wall-clock nanoseconds and are not normalized at all. All caveats about the overall `time_in_nanos` apply here. The intention of the breakdown is to give you a feel for A) what machinery in Lucene is actually eating time, and B) the magnitude of differences in times between the various components. Like the overall time, the breakdown is inclusive of all children times. @@ -412,6 +433,9 @@ Looking at the previous example: } ] ``` +% TESTRESPONSE[s/^/{\n"took": $body.took,\n"timed_out": $body.timed_out,\n"_shards": $body._shards,\n"hits": $body.hits,\n"profile": {\n"shards": [ {\n"id": "$body.profile.shards.0.id",\n"node_id": "$body.profile.shards.0.node_id",\n"shard_id": $body.profile.shards.0.shard_id,\n"index": "$body.profile.shards.0.index",\n"cluster": "(local)",\n"searches": [{\n"query": $body.$_path,\n"rewrite_time": $body.$_path,/] +% TESTRESPONSE[s/]$/]}], "aggregations": [], "fetch": $body.$_path}]}}/] +% TESTRESPONSE[s/(?<=[" ])\d+(\.\d+)?/$body.$_path/] We see a top-level collector named `QueryPhaseCollector` which holds a child `SimpleTopScoreDocCollector`. `SimpleTopScoreDocCollector` is the default "scoring and sorting" `Collector` used by {{es}}. The `reason` field attempts to give a plain English description of the class name. The `time_in_nanos` is similar to the time in the Query tree: a wall-clock time inclusive of all children. Similarly, `children` lists all sub-collectors. When aggregations are requested, the `QueryPhaseCollector` will hold an additional child collector with reason `aggregation` that is the one performing aggregations. @@ -484,6 +508,8 @@ GET /my-index-000001/_search } } ``` +% TEST[setup:my_index] +% TEST[s/_search/_search\?filter_path=profile.shards.id,profile.shards.node_id,profile.shards.shard_id,profile.shards.index,profile.shards.cluster,profile.shards.searches,profile.shards.aggregations,profile.shards.fetch/] This example has: @@ -592,6 +618,12 @@ The API returns the following result: } } ``` +% TESTRESPONSE[s/"aggregations": \[\.\.\.\]/"aggregations": $body.$_path/] +% TESTRESPONSE[s/"fetch": \{\.\.\.\}/"fetch": $body.$_path/] +% TESTRESPONSE[s/\.\.\.//] +% TESTRESPONSE[s/(?<=[" ])\d+(\.\d+)?/$body.$_path/] +% TESTRESPONSE[s/"id": "\[P6xvulHtQRWuD4YnubWb7A\]\[my-index-000001\]\[0\]"/"id": $body.profile.shards.0.id/] +% TESTRESPONSE[s/"node_id": "P6xvulHtQRWuD4YnubWb7A",/"node_id": "$body.profile.shards.0.node_id",/] 1. The `"aggregations"` portion has been omitted because it will be covered in the next section. @@ -656,6 +688,8 @@ GET /my-index-000001/_search } } ``` +% TEST[s/_search/_search\?filter_path=profile.shards.aggregations/] +% TEST[continued] This yields the following aggregation profile output: @@ -743,6 +777,9 @@ This yields the following aggregation profile output: } } ``` +% TESTRESPONSE[s/\.\.\.//] +% TESTRESPONSE[s/(?>=[" ])\d+(\.\d+)?/$body.$_path/] +% TESTRESPONSE[s/"id": "\[P6-vulHtQRWuD4YnubWb7A\]\[my-index-000001\]\[0\]"/"id": $body.profile.shards.0.id/] From the profile structure we can see that the `my_scoped_agg` is internally being run as a `NumericTermsAggregator` (because the field it is aggregating, `http.response.status_code`, is a numeric field). At the same level, we see a `GlobalAggregator` which comes from `my_global_agg`. That aggregation then has a child `NumericTermsAggregator` which comes from the second term’s aggregation on `http.response.status_code`. @@ -768,6 +805,7 @@ The `breakdown` component lists detailed statistics about low-level execution: "build_leaf_collector_count": 1 } ``` +% NOTCONSOLE Each property in the `breakdown` component corresponds to an internal method for the aggregation. For example, the `build_leaf_collector` property measures nanoseconds spent running the aggregation’s `getLeafCollector()` method. Properties ending in `_count` record the number of invocations of the particular method. For example, `"collect_count": 2` means the aggregation called the `collect()` on two different documents. The `reduce` property is reserved for future use and always returns `0`. @@ -791,6 +829,7 @@ GET /my-index-000001/_search?filter_path=profile.shards.fetch } } ``` +% TEST[continued] And here is the fetch profile: @@ -858,6 +897,7 @@ And here is the fetch profile: } } ``` +% TESTRESPONSE[s/(?>=[" ])\d+(\.\d+)?/$body.$_path/] Since this is debugging information about the way that Elasticsearch executes the fetch it can change from request to request and version to version. Even patch versions may change the output here. That lack of consistency is what makes it useful for debugging. @@ -929,6 +969,7 @@ GET /my-dfs-index/_search?search_type=dfs_query_then_fetch&pretty&size=0 <1> } } ``` +% TEST[continued] 1. The `search_type` url parameter is set to `dfs_query_then_fetch` to ensure the dfs phase is run. 2. The `profile` parameter is set to `true`. @@ -955,6 +996,9 @@ In the response, we see a profile which includes a `dfs` section for each shard } } ``` +% TESTRESPONSE[s/^/{\n"took": $body.took,\n"timed_out": $body.timed_out,\n"_shards": $body._shards,\n"hits": $body.hits,\n"profile": {\n"shards": [ "$body.$_path", {\n"id": "$body.$_path",\n"node_id": "$body.$_path",\n"shard_id": "$body.$_path",\n"index": "$body.$_path",\n"cluster": "$body.$_path",\n/] +% TESTRESPONSE[s/}$/}, "aggregations": [], "searches": $body.$_path}]}}/] +% TESTRESPONSE[s/(\-)?[0-9]+/ $body.$_path/] In the `dfs.statistics` portion of this response we see a `time_in_nanos` which is the total time it took to collect term statistics for this shard along with a further breakdown of the individual parts. @@ -992,6 +1036,7 @@ POST my-knn-index/_bulk?refresh=true { "index": { "_id": "3" } } { "my-vector": [15, 11, 23] } ``` +% TEST[skip:response format changes in 130254] With an index setup, we can now profile a kNN search query. @@ -1007,6 +1052,7 @@ POST my-knn-index/_search } } ``` +% TEST[skip:response format changes in 130254] 1. The `profile` parameter is set to `true`. @@ -1060,6 +1106,7 @@ One of the `dfs.knn` sections for a shard looks like the following: } ] } ``` +% TESTRESPONSE[skip:response format changes in 130254] In the `dfs.knn` portion of the response we can see the output the of timings for [query](search-profile.md#query-section), [rewrite](search-profile.md#rewrite-section), and [collector](search-profile.md#collectors-section). Unlike many other queries, kNN search does the bulk of the work during the query rewrite. This means `rewrite_time` represents the time spent on kNN search. The attribute `vector_operations_count` represents the overall count of vector operations performed during the kNN search. diff --git a/docs/reference/elasticsearch/rest-apis/search-rank-eval.md b/docs/reference/elasticsearch/rest-apis/search-rank-eval.md index 7485771d2a125..8d21fb1cd8776 100644 --- a/docs/reference/elasticsearch/rest-apis/search-rank-eval.md +++ b/docs/reference/elasticsearch/rest-apis/search-rank-eval.md @@ -38,7 +38,7 @@ For full details about the API syntax, refer to: In its most basic form, a request to the `_rank_eval` endpoint has two sections: -```console +```js GET /my-index-000001/_rank_eval { "requests": [ ... ], <1> @@ -47,6 +47,7 @@ GET /my-index-000001/_rank_eval } } ``` +% NOTCONSOLE 1. A set of typical search requests, together with their provided ratings. 2. A definition of the evaluation metric to calculate. @@ -54,7 +55,7 @@ GET /my-index-000001/_rank_eval The request section contains several search requests typical to your application, along with the document ratings for each particular search request. -```console +```js GET /my-index-000001/_rank_eval { "requests": [ @@ -81,6 +82,7 @@ GET /my-index-000001/_rank_eval ] } ``` +% NOTCONSOLE 1. The search request's ID, used to group result details later. 2. The query being evaluated. @@ -101,7 +103,7 @@ As an alternative to having to provide a single query per test request, it is po This way, queries with a similar structure that differ only in their parameters don't have to be repeated all the time in the `requests` section. In typical search systems, where user inputs usually get filled into a small set of query templates, this helps make the evaluation request more succinct. -```console +```js GET /my-index-000001/_rank_eval { [...] @@ -131,6 +133,7 @@ GET /my-index-000001/_rank_eval ] } ``` +% NOTCONSOLE 1. The template ID. 2. The template definition to use. @@ -140,7 +143,7 @@ GET /my-index-000001/_rank_eval You can also use a stored [search template](docs-content://solutions/search/search-templates.md). For example: -```console +```js GET /my_index/_rank_eval { [...] @@ -155,6 +158,7 @@ GET /my_index/_rank_eval "requests": [...] } ``` +% NOTCONSOLE 1. The template ID used for requests. 2. The template ID stored in the cluster state. @@ -193,6 +197,7 @@ GET /my-index-000001/_rank_eval } } ``` +% TEST[setup:my_index] The `precision` metric takes optional parameters, including: @@ -232,6 +237,7 @@ GET /my-index-000001/_rank_eval } } ``` +% TEST[setup:my_index] The `recall` metric takes optional parameters including: @@ -265,6 +271,7 @@ GET /my-index-000001/_rank_eval } } ``` +% TEST[setup:my_index] The `mean_reciprocal_rank` metric takes optional parameters including: @@ -299,6 +306,7 @@ GET /my-index-000001/_rank_eval } } ``` +% TEST[setup:my_index] The `dcg` metric takes optional parameters including: @@ -339,6 +347,7 @@ GET /my-index-000001/_rank_eval } } ``` +% TEST[setup:my_index] The `expected_reciprocal_rank` metric takes parameters including: @@ -391,6 +400,7 @@ The response has the following format: } } ``` +% NOTCONSOLE 1. The overall evaluation quality calculated by the defined metric. 2. The `details` section contains one entry for every query in the original `requests` section, keyed by the search request ID. diff --git a/docs/reference/elasticsearch/rest-apis/search-shard-routing.md b/docs/reference/elasticsearch/rest-apis/search-shard-routing.md index 61fb63fac8630..a2ed9ec8df662 100644 --- a/docs/reference/elasticsearch/rest-apis/search-shard-routing.md +++ b/docs/reference/elasticsearch/rest-apis/search-shard-routing.md @@ -39,6 +39,7 @@ GET /my-index-000001/_search?preference=_local } } ``` +% TEST[setup:my_index] You can also use the `preference` parameter to route searches to specific shards based on a provided string. If the cluster state and selected shards do not change, searches using the same `preference` string are routed to the same shards in the same order. @@ -61,6 +62,7 @@ GET /my-index-000001/_search?preference=my-custom-shard-string } } ``` +% TEST[setup:my_index] ::::{note} If the cluster state or selected shards change, the same `preference` string may not route searches to the same shards in the same order. This can occur for a number of reasons, including shard relocations and shard failures. A node can also reject a search request, which {{es}} would re-route to another node. @@ -84,6 +86,7 @@ POST /my-index-000001/_doc?routing=my-routing-value } } ``` +% TEST[setup:my_index] You can use the same routing value in the search API’s `routing` query parameter. This ensures the search runs on the same shard used to index the document. @@ -97,6 +100,7 @@ GET /my-index-000001/_search?routing=my-routing-value } } ``` +% TEST[setup:my_index] You can also provide multiple comma-separated routing values: @@ -110,7 +114,7 @@ GET /my-index-000001/_search?routing=my-routing-value,my-routing-value-2 } } ``` - +% TEST[setup:my_index] ## Search concurrency and parallelism [search-concurrency-and-parallelism] @@ -133,6 +137,7 @@ GET /my-index-000001/_search?max_concurrent_shard_requests=3 } } ``` +% TEST[setup:my_index] You can also use the `action.search.shard_count.limit` cluster setting to set a search shard limit and reject requests that hit too many shards. You can configure `action.search.shard_count.limit` using the [cluster settings API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings). diff --git a/docs/reference/elasticsearch/rest-apis/search-suggesters.md b/docs/reference/elasticsearch/rest-apis/search-suggesters.md index 937bf7a7e9a8b..1ae7637ba7367 100644 --- a/docs/reference/elasticsearch/rest-apis/search-suggesters.md +++ b/docs/reference/elasticsearch/rest-apis/search-suggesters.md @@ -20,7 +20,7 @@ POST _search { "suggest": { "my-suggest-1" : { - "text" : "tring out Elasticsearch", + "text" : "trying out Elasticsearch", "term" : { "field" : "message" } @@ -34,6 +34,8 @@ POST _search } } ``` +% TEST[setup:messages] +% TEST[s/^/PUT my-index-000001\/_mapping\n{"properties":{"user":{"properties":{"id":{"type":"keyword"}}}}}\n/] The following suggest response example includes the suggestion response for `my-suggest-1` and `my-suggest-2`. Each suggestion part contains entries. Each entry is effectively a token from the suggest text and contains the suggestion entry text, the original start offset and length in the suggest text and if found an arbitrary number of options. @@ -64,6 +66,10 @@ The following suggest response example includes the suggestion response for `my- } } ``` +% TESTRESPONSE[s/"_shards": \.\.\./"_shards": "$body._shards",/] +% TESTRESPONSE[s/"hits": .../"hits": "$body.hits",/] +% TESTRESPONSE[s/"took": 2,/"took": "$body.took",/] +% TESTRESPONSE[s/"my-suggest-2": \.\.\./"my-suggest-2": "$body.suggest.my-suggest-2"/] Each options array contains an option object that includes the suggested text, its document frequency and score compared to the suggest entry text. The meaning of the score depends on the used suggester. The term suggester's score is based on the edit distance. @@ -90,6 +96,8 @@ POST _search } } ``` +% TEST[setup:messages] +% TEST[s/^/PUT my-index-000001\/_mapping\n{"properties":{"user":{"properties":{"id":{"type":"keyword"}}}}}\n/] The suggest text can in the above example also be specified as suggestion specific option. The suggest text specified on suggestion level override the suggest text on the global level. @@ -267,6 +275,9 @@ The response contains suggestions scored by the most likely spelling correction } } ``` +% TESTRESPONSE[s/"_shards": …​/"_shards": "$body._shards",/] +% TESTRESPONSE[s/"hits": …​/"hits": "$body.hits",/] +% TESTRESPONSE[s/"took": 3,/"took": "$body.took",/] $$$_basic_phrase_suggest_api_parameters$$$ Basic phrase suggest API parameters include: @@ -507,6 +518,7 @@ PUT music/_doc/1?refresh } } ``` +% TEST The supported parameters include: @@ -543,6 +555,7 @@ PUT music/_doc/1?refresh ] } ``` +% TEST[continued] You can use the following shorthand form. Note that you can not specify a weight with suggestion(s) in the shorthand form. @@ -552,7 +565,7 @@ PUT music/_doc/1?refresh "suggest" : [ "Nevermind", "Nirvana" ] } ``` - +% TEST[continued] ### Querying [querying] @@ -571,6 +584,7 @@ POST music/_search?pretty } } ``` +% TEST[continued] 1. Prefix used to search for suggestions 2. Type of suggestions @@ -607,6 +621,8 @@ It returns this response: } } ``` +% TESTRESPONSE[s/"hits": …​/"hits": "$body.hits",/] +% TESTRESPONSE[s/"took": 2,/"took": "$body.took",/] ::::{important} `_source` metadata field must be enabled, which is the default behavior, to enable returning `_source` with suggestions. @@ -629,6 +645,7 @@ POST music/_search } } ``` +% TEST[continued] 1. Filter the source to return only the `suggest` field 2. Name of the field to search for suggestions in @@ -673,6 +690,7 @@ Which should look like: } } ``` +% TESTRESPONSE[s/"took": 6,/"took": $body.took,/] The supported parameters for a basic completion suggester query include: @@ -918,6 +936,7 @@ POST place/_search?pretty } } ``` +% TEST[continued] ::::{note} If multiple categories or category contexts are set on the query they are merged as a disjunction. This means that suggestions match if they contain at least one of the provided context values. @@ -945,6 +964,7 @@ POST place/_search?pretty } } ``` +% TEST[continued] 1. The context query filter suggestions associated with categories *cafe* and *restaurants* and boosts the suggestions associated with *restaurants* by a factor of `2` @@ -1030,6 +1050,7 @@ POST place/_search } } ``` +% TEST[continued] ::::{note} When a location with a lower precision at query time is specified, all suggestions that fall within the area will be considered. @@ -1069,6 +1090,7 @@ POST place/_search?pretty } } ``` +% TEST[continued] 1. The context query filters for suggestions that fall under the geo location represented by a geohash of *(43.662, -79.380)* with a precision of *2* and boosts suggestions that fall under the geohash representation of *(43.6624803, -79.3863353)* with a default precision of *6* by a factor of `2` @@ -1119,6 +1141,7 @@ POST _search?typed_keys } } ``` +% TEST[continued] In the response, the suggester names will be changed to respectively `term#my-first-suggester` and `phrase#my-second-suggester`, reflecting the types of each suggestion: @@ -1168,6 +1191,9 @@ In the response, the suggester names will be changed to respectively `term#my-fi ... } ``` +% TESTRESPONSE[s/\.\.\./"took": "$body.took", "timed_out": false, "_shards": "$body._shards", "hits": "$body.hits"/] +% TESTRESPONSE[s/"score": 0.8333333/"score": $body.suggest.term#my-first-suggester.2.options.0.score/] +% TESTRESPONSE[s/"score": 0.030227963/"score": $body.suggest.phrase#my-second-suggester.0.options.0.score/] 1. The name `my-first-suggester` now contains the `term` prefix. 2. The name `my-second-suggester` now contains the `phrase` prefix. diff --git a/docs/reference/elasticsearch/rest-apis/searching-with-query-rules.md b/docs/reference/elasticsearch/rest-apis/searching-with-query-rules.md index 874066b255c94..918f128256360 100644 --- a/docs/reference/elasticsearch/rest-apis/searching-with-query-rules.md +++ b/docs/reference/elasticsearch/rest-apis/searching-with-query-rules.md @@ -82,6 +82,13 @@ The following command will create a query ruleset called `my-ruleset` with two q * The first rule will generate a [Pinned Query](/reference/query-languages/query-dsl/query-dsl-pinned-query.md) pinning the [`_id`](/reference/elasticsearch/mapping-reference/mapping-id-field.md)s `id1` and `id2` when the `query_string` metadata value is a fuzzy match to either `puggles` or `pugs` *and* the user’s location is in the US. * The second rule will generate a query that excludes the [`_id`](/reference/elasticsearch/mapping-reference/mapping-id-field.md) `id3` specifically from the `my-index-000001` index and `id4` from the `my-index-000002` index when the `query_string` metadata value contains `beagles`. + + ```console PUT /_query_rules/my-ruleset { @@ -147,6 +154,7 @@ There is a limit of 100 rules per ruleset. This can be increased up to 1000 usin "result": "created" } ``` +% TEST[continued] You can use the [Get query ruleset](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-get-ruleset) call to retrieve the ruleset you just created, the [List query rulesets](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-list-rulesets) call to retrieve a summary of all query rulesets, and the [Delete query ruleset](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-delete-ruleset) call to delete a query ruleset. @@ -184,6 +192,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] This rule query will match against `rule1` in the defined query ruleset, and will convert the organic query into a pinned query with `id1` and `id2` pinned as the top hits. Any other matches from the organic query will be returned below the pinned results. @@ -235,6 +244,7 @@ GET my-index-000001/_search } } ``` +% TEST[continued] This will apply pinned and excluded query rules on top of the content that was reranked by RRF. diff --git a/docs/reference/elasticsearch/rest-apis/shard-request-cache.md b/docs/reference/elasticsearch/rest-apis/shard-request-cache.md index f65b0bdb1c142..97ef2f37c0c9a 100644 --- a/docs/reference/elasticsearch/rest-apis/shard-request-cache.md +++ b/docs/reference/elasticsearch/rest-apis/shard-request-cache.md @@ -31,6 +31,7 @@ The cache can be expired manually with the [clear cache API](https://www.elastic ```console POST /my-index-000001,my-index-000002/_cache/clear?request=true ``` +% TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/] ## Enabling and disabling caching [_enabling_and_disabling_caching] @@ -53,6 +54,7 @@ PUT /my-index-000001/_settings "index.requests.cache.enable": true } ``` +% TEST[continued] ## Enabling and disabling caching per request [_enabling_and_disabling_caching_per_request] @@ -71,6 +73,7 @@ GET /my-index-000001/_search?request_cache=true } } ``` +% TEST[continued] Requests where `size` is greater than `0` will not be cached even if the request cache is enabled in the index settings. To cache these requests you will need to use the query parameter. diff --git a/docs/reference/elasticsearch/rest-apis/sort-search-results.md b/docs/reference/elasticsearch/rest-apis/sort-search-results.md index 455dd7258fa07..b9822d4970f7c 100644 --- a/docs/reference/elasticsearch/rest-apis/sort-search-results.md +++ b/docs/reference/elasticsearch/rest-apis/sort-search-results.md @@ -46,6 +46,8 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] + Order matters when defining multiple sort fields, because {{es}} attempts to sort on the first field in the array. Each subsequent field in the array is only used if the previous fields result in a tie. If documents have identical values across all specified sort fields, {{es}} uses the document ID as the final tie-breaker. Here's how the example query attempts to sort results: @@ -79,7 +81,7 @@ GET /my-index-000001/_search } } ``` - +% TEST[continued] ## Sort order [_sort_order] @@ -166,6 +168,7 @@ PUT /index_long } } ``` +% TEST[continued] Since `field` is mapped as a `double` in the first index and as a `long` in the second index, it is not possible to use this field to sort requests that query both indices by default. However you can force the type to one or the other with the `numeric_type` option in order to force a specific type for all indices: @@ -181,6 +184,7 @@ POST /index_long,index_double/_search ] } ``` +% TEST[continued] In the example above, values for the `index_long` index are casted to a double in order to be compatible with the values produced by the `index_double` index. It is also possible to transform a floating point field into a `long` but note that in this case floating points are replaced by the largest value that is less than or equal (greater than or equal if the value is negative) to the argument and is equal to a mathematical integer. @@ -207,6 +211,7 @@ PUT /index_long } } ``` +% TEST[continued] Values in these indices are stored with different resolutions so sorting on these fields will always sort the `date` before the `date_nanos` (ascending order). With the `numeric_type` type option it is possible to set a single resolution for the sort, setting to `date` will convert the `date_nanos` to the millisecond resolution while `date_nanos` will convert the values in the `date` field to the nanoseconds resolution: @@ -222,6 +227,7 @@ POST /index_long,index_double/_search ] } ``` +% TEST[continued] ::::{warning} To avoid overflow, the conversion to `date_nanos` cannot be applied on dates before 1970 and after 2262 as nanoseconds are represented as longs. diff --git a/docs/reference/elasticsearch/rest-apis/term-vectors-examples.md b/docs/reference/elasticsearch/rest-apis/term-vectors-examples.md index 270393dd8307b..05e78efdede6b 100644 --- a/docs/reference/elasticsearch/rest-apis/term-vectors-examples.md +++ b/docs/reference/elasticsearch/rest-apis/term-vectors-examples.md @@ -66,7 +66,6 @@ PUT /my-index-000001/_doc/2?refresh=wait_for "text" : "Another test ..." } ``` - % TEST[continued] The following request returns all information and statistics for field @@ -83,7 +82,6 @@ GET /my-index-000001/_termvectors/1 "field_statistics" : true } ``` - % TEST[continued] Response: @@ -133,7 +131,6 @@ Response: } } ``` - % TEST[continued] % TESTRESPONSE[s/"took": 6/"took": "$body.took"/] @@ -154,7 +151,6 @@ GET /my-index-000001/_termvectors/1 "field_statistics" : true } ``` - % TEST[continued] ## Artificial documents [docs-termvectors-artificial-doc] @@ -174,7 +170,6 @@ GET /my-index-000001/_termvectors } } ``` - % TEST[continued] ## Per-field analyzer [docs-termvectors-per-field-analyzer] @@ -198,7 +193,6 @@ GET /my-index-000001/_termvectors } } ``` - % TEST[continued] Response: @@ -232,7 +226,6 @@ Response: } } ``` - % TEST[continued] % TESTRESPONSE[s/"took": 6/"took": "$body.took"/] % TESTRESPONSE[s/"sum_doc_freq": 2/"sum_doc_freq": "$body.term_vectors.fullname.field_statistics.sum_doc_freq"/] @@ -264,7 +257,6 @@ GET /imdb/_termvectors } } ``` - % TEST[skip:no imdb test index] Response: diff --git a/docs/reference/elasticsearch/rest-apis/update-cc-api-key-examples.md b/docs/reference/elasticsearch/rest-apis/update-cc-api-key-examples.md index a7a08f4333b32..e434e0bd74f00 100644 --- a/docs/reference/elasticsearch/rest-apis/update-cc-api-key-examples.md +++ b/docs/reference/elasticsearch/rest-apis/update-cc-api-key-examples.md @@ -38,7 +38,6 @@ A successful call returns a JSON structure that provides API key information. Fo "encoded": "VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==" } ``` - % TESTRESPONSE[s/VuaCfGcBCdbkQm-e5aOx/$body.id/] % TESTRESPONSE[s/ui2lp2axTNmsyakw9tvNnw/$body.api_key/] % TESTRESPONSE[s/VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==/$body.encoded/] @@ -50,7 +49,6 @@ To retrieve key information about the API key, including the exact role descript ```console GET /_security/api_key?id=VuaCfGcBCdbkQm-e5aOx ``` - % TEST[s/VuaCfGcBCdbkQm-e5aOx/$body.id/] % TEST[continued] @@ -109,7 +107,6 @@ A successful call returns a JSON structure that contains the information of the ] } ``` - % NOTCONSOLE 1. Role descriptor corresponding to the specified `access` scope at creation time. @@ -135,7 +132,6 @@ PUT /_security/cross_cluster/api_key/VuaCfGcBCdbkQm-e5aOx } } ``` - % TEST[s/VuaCfGcBCdbkQm-e5aOx/\${body.api_keys.0.id}/] % TEST[continued] @@ -202,7 +198,6 @@ The API key's permissions after the update can be inspected again with the [Get ] } ``` - % NOTCONSOLE 1. Role descriptor is updated to be the `access` scope specified at update time. diff --git a/docs/reference/elasticsearch/rest-apis/update-document.md b/docs/reference/elasticsearch/rest-apis/update-document.md index 124d7fcc46fa9..373b6fe49726b 100644 --- a/docs/reference/elasticsearch/rest-apis/update-document.md +++ b/docs/reference/elasticsearch/rest-apis/update-document.md @@ -101,6 +101,7 @@ POST test/_update/1 The following script removes a subfield from an object field: + ```console POST test/_update/1 @@ -171,8 +173,7 @@ POST test/_update/1 If the value of `name` is already `new_name`, the update request is ignored and the `result` element in the response returns `noop`: -```console - +```js { "_shards": { "total": 0, @@ -187,6 +188,7 @@ request is ignored and the `result` element in the response returns `noop`: "result": "noop" } ``` +% NOTCONSOLE You can disable this behavior by setting `"detect_noop": false`: diff --git a/docs/reference/elasticsearch/rest-apis/vector-tile-search.md b/docs/reference/elasticsearch/rest-apis/vector-tile-search.md index 0acb4cab14a3c..772525ed45d55 100644 --- a/docs/reference/elasticsearch/rest-apis/vector-tile-search.md +++ b/docs/reference/elasticsearch/rest-apis/vector-tile-search.md @@ -274,6 +274,26 @@ tile contains the following data: `grid_agg` argument of `geotile` and an `exact_bounds` argument of `true` into the following search: + + ```console GET my-index/_search { diff --git a/docs/reference/enrich-processor/append-processor.md b/docs/reference/enrich-processor/append-processor.md index 14d9ac8e5dd1c..ed50a8cb025b1 100644 --- a/docs/reference/enrich-processor/append-processor.md +++ b/docs/reference/enrich-processor/append-processor.md @@ -39,6 +39,7 @@ Here is an `append` processor definition that adds the string `"production"` as } } ``` +% NOTCONSOLE ### Example using `allow_duplicates` and `ignore_empty_values` [append-processor-example-using-allow-duplicates-and-ignore-empty-values] @@ -58,3 +59,4 @@ By using `allow_duplicates` and `ignore_empty_values`, it is possible to only ap } } ``` +% NOTCONSOLE \ No newline at end of file diff --git a/docs/reference/enrich-processor/attachment.md b/docs/reference/enrich-processor/attachment.md index 02fa88bee4d8b..08496a9896856 100644 --- a/docs/reference/enrich-processor/attachment.md +++ b/docs/reference/enrich-processor/attachment.md @@ -79,6 +79,7 @@ The document’s `attachment` object contains extracted properties for the file: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] ## Exported fields [attachment-fields] @@ -183,6 +184,7 @@ The document’s `_source` object includes the original binary field: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] ## Use the attachment processor with CBOR [attachment-cbor] @@ -280,6 +282,7 @@ Returns this: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] ```console PUT _ingest/pipeline/attachment @@ -325,6 +328,7 @@ Returns this: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] ## Using the attachment processor with arrays [attachment-with-arrays] @@ -347,6 +351,7 @@ For example, given the following source: ] } ``` +% NOTCONSOLE In this case, we want to process the data field in each element of the attachments field and insert the properties into the document so the following `foreach` processor is used: @@ -419,6 +424,7 @@ Returns this: } } ``` +% TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] Note that the `target_field` needs to be set, otherwise the default value is used which is a top level field `attachment`. The properties on this top level field will contain the value of the first attachment only. However, by specifying the `target_field` on to a value on `_ingest._value` it will correctly associate the properties with the correct attachment. diff --git a/docs/reference/enrich-processor/bytes-processor.md b/docs/reference/enrich-processor/bytes-processor.md index 18fabdd3b9911..079d15d0a4827 100644 --- a/docs/reference/enrich-processor/bytes-processor.md +++ b/docs/reference/enrich-processor/bytes-processor.md @@ -31,4 +31,5 @@ $$$bytes-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/community-id-processor.md b/docs/reference/enrich-processor/community-id-processor.md index 643a6bf984935..1556bd5561fd0 100644 --- a/docs/reference/enrich-processor/community-id-processor.md +++ b/docs/reference/enrich-processor/community-id-processor.md @@ -45,6 +45,7 @@ Here is an example definition of the community ID processor: ] } ``` +% NOTCONSOLE When the above processor executes on the following document: @@ -65,6 +66,7 @@ When the above processor executes on the following document: } } ``` +% NOTCONSOLE It produces this result: @@ -84,4 +86,5 @@ It produces this result: } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/convert-processor.md b/docs/reference/enrich-processor/convert-processor.md index 5905fbd22dfde..09f6e85f1ac0f 100644 --- a/docs/reference/enrich-processor/convert-processor.md +++ b/docs/reference/enrich-processor/convert-processor.md @@ -69,4 +69,5 @@ PUT _ingest/pipeline/my-pipeline-id ] } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/csv-processor.md b/docs/reference/enrich-processor/csv-processor.md index cc0ce9757acd4..03fa9deb64782 100644 --- a/docs/reference/enrich-processor/csv-processor.md +++ b/docs/reference/enrich-processor/csv-processor.md @@ -34,6 +34,7 @@ $$$csv-options$$$ } } ``` +% NOTCONSOLE If the `trim` option is enabled then any whitespace in the beginning and in the end of each unquoted field will be trimmed. For example with configuration above, a value of `A, B` will result in field `field2` having value `{{nbsp}}B` (with space at the beginning). If `trim` is enabled `A, B` will result in field `field2` having value `B` (no whitespace). Quoted fields will be left untouched. diff --git a/docs/reference/enrich-processor/date-index-name-processor.md b/docs/reference/enrich-processor/date-index-name-processor.md index 8e650e1aeb9e1..31c3c27317b78 100644 --- a/docs/reference/enrich-processor/date-index-name-processor.md +++ b/docs/reference/enrich-processor/date-index-name-processor.md @@ -39,6 +39,7 @@ PUT /my-index/_doc/1?pipeline=monthlyindex "date1" : "2016-04-25T12:02:01.789Z" } ``` +% TEST[continued] ```console-result { @@ -55,6 +56,7 @@ PUT /my-index/_doc/1?pipeline=monthlyindex "_primary_term" : 1 } ``` +% TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] The above request will not index this document into the `my-index` index, but into the `my-index-2016-04-01` index because it was rounded by month. This is because the date-index-name-processor overrides the `_index` property of the document. @@ -107,6 +109,7 @@ and the result: ] } ``` +% TESTRESPONSE[s/2016-11-08T19:43:03.850\+0000/$body.docs.0.doc._ingest.timestamp/] The above example shows that `_index` was set to ``. Elasticsearch understands this to mean `2016-04-01` as is explained in the [date math index name documentation](/reference/elasticsearch/rest-apis/api-conventions.md#api-date-math-index-names) diff --git a/docs/reference/enrich-processor/date-processor.md b/docs/reference/enrich-processor/date-processor.md index 1c2acfd6653f0..5720424e197ad 100644 --- a/docs/reference/enrich-processor/date-processor.md +++ b/docs/reference/enrich-processor/date-processor.md @@ -55,6 +55,7 @@ Here is an example that adds the parsed date to the `timestamp` field based on t ] } ``` +% NOTCONSOLE ### Example using templated parameters [date-processor-templated-example] @@ -76,6 +77,7 @@ The `timezone` and `locale` processor parameters are templated. This means that ] } ``` +% NOTCONSOLE ### Example dealing with short timezone abbreviations safely [date-processor-short-timezone-example] diff --git a/docs/reference/enrich-processor/dissect-processor.md b/docs/reference/enrich-processor/dissect-processor.md index cadc22921ebdb..831c65159520d 100644 --- a/docs/reference/enrich-processor/dissect-processor.md +++ b/docs/reference/enrich-processor/dissect-processor.md @@ -43,6 +43,7 @@ and result in a document with the following fields: } } ``` +% NOTCONSOLE A dissect pattern is defined by the parts of the string that will be discarded. In the previous example, the first part to be discarded is a single space. Dissect finds this space, then assigns the value of `clientip` everything up until that space. Next, dissect matches the `[` and then `]` and then assigns `@timestamp` to everything in-between `[` and `]`. Paying special attention to the parts of the string to discard will help build successful dissect patterns. @@ -72,6 +73,7 @@ $$$dissect-options$$$ } } ``` +% NOTCONSOLE ## Dissect key modifiers [dissect-key-modifiers] diff --git a/docs/reference/enrich-processor/dot-expand-processor.md b/docs/reference/enrich-processor/dot-expand-processor.md index 92eed478491eb..ac6c2526800cf 100644 --- a/docs/reference/enrich-processor/dot-expand-processor.md +++ b/docs/reference/enrich-processor/dot-expand-processor.md @@ -29,6 +29,7 @@ $$$dot-expander-options$$$ } } ``` +% NOTCONSOLE For example the dot expand processor would turn this document: @@ -37,6 +38,7 @@ For example the dot expand processor would turn this document: "foo.bar" : "value" } ``` +% NOTCONSOLE into: @@ -47,6 +49,7 @@ into: } } ``` +% NOTCONSOLE If there is already a `bar` field nested under `foo` then this processor merges the `foo.bar` field into it. If the field is a scalar value then it will turn that field into an array field. @@ -60,6 +63,7 @@ For example, the following document: } } ``` +% NOTCONSOLE is transformed by the `dot_expander` processor into: @@ -70,6 +74,7 @@ is transformed by the `dot_expander` processor into: } } ``` +% NOTCONSOLE Contrast that with when the `override` option is set to `true`. @@ -81,6 +86,7 @@ Contrast that with when the `override` option is set to `true`. } } ``` +% NOTCONSOLE In that case, the value of the expanded field overrides the value of the nested object. @@ -91,6 +97,7 @@ In that case, the value of the expanded field overrides the value of the nested } } ``` +% NOTCONSOLE
The value of `field` can also be set to a `*` to expand all top-level dotted field names: @@ -102,6 +109,7 @@ The value of `field` can also be set to a `*` to expand all top-level dotted fie } } ``` +% NOTCONSOLE The dot expand processor would turn this document: @@ -111,6 +119,7 @@ The dot expand processor would turn this document: "baz.qux" : "value" } ``` +% NOTCONSOLE into: @@ -124,6 +133,7 @@ into: } } ``` +% NOTCONSOLE
If the dotted field is nested within a non-dotted structure, then use the `path` option to navigate the non-dotted structure: @@ -136,6 +146,7 @@ If the dotted field is nested within a non-dotted structure, then use the `path` } } ``` +% NOTCONSOLE The dot expand processor would turn this document: @@ -147,6 +158,7 @@ The dot expand processor would turn this document: } } ``` +% NOTCONSOLE into: @@ -160,6 +172,7 @@ into: } } ``` +% NOTCONSOLE
If any field outside of the leaf field conflicts with a pre-existing field of the same name, then that field needs to be renamed first. @@ -172,6 +185,7 @@ Consider the following document: "foo.bar": "value2" } ``` +% NOTCONSOLE Then the `foo` needs to be renamed first before the `dot_expander` processor is applied. So in order for the `foo.bar` field to properly be expanded into the `bar` field under the `foo` field the following pipeline should be used: @@ -192,6 +206,7 @@ Then the `foo` needs to be renamed first before the `dot_expander` processor is ] } ``` +% NOTCONSOLE The reason for this is that Ingest doesn’t know how to automatically cast a scalar field to an object field. diff --git a/docs/reference/enrich-processor/drop-processor.md b/docs/reference/enrich-processor/drop-processor.md index b6b5fcb1baf57..d970741c774b9 100644 --- a/docs/reference/enrich-processor/drop-processor.md +++ b/docs/reference/enrich-processor/drop-processor.md @@ -26,4 +26,5 @@ $$$drop-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/fail-processor.md b/docs/reference/enrich-processor/fail-processor.md index 514971caae23f..dabec866f5059 100644 --- a/docs/reference/enrich-processor/fail-processor.md +++ b/docs/reference/enrich-processor/fail-processor.md @@ -28,4 +28,5 @@ $$$fail-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/fingerprint-processor.md b/docs/reference/enrich-processor/fingerprint-processor.md index 7c978c83ce429..26cc009449f67 100644 --- a/docs/reference/enrich-processor/fingerprint-processor.md +++ b/docs/reference/enrich-processor/fingerprint-processor.md @@ -78,4 +78,5 @@ Which produces the following result: ] } ``` +% TESTRESPONSE[s/\.\.\./"_index":"_index","_id":"_id","_version":"-3","_ingest":{"timestamp":$body.docs.0.doc._ingest.timestamp},/] diff --git a/docs/reference/enrich-processor/foreach-processor.md b/docs/reference/enrich-processor/foreach-processor.md index 43bba4e4bd10f..cc5b114678e4d 100644 --- a/docs/reference/enrich-processor/foreach-processor.md +++ b/docs/reference/enrich-processor/foreach-processor.md @@ -60,6 +60,7 @@ Assume the following document: "values" : ["foo", "bar", "baz"] } ``` +% NOTCONSOLE When this `foreach` processor operates on this sample document: @@ -75,6 +76,7 @@ When this `foreach` processor operates on this sample document: } } ``` +% NOTCONSOLE Then the document will look like this after processing: @@ -83,6 +85,7 @@ Then the document will look like this after processing: "values" : ["FOO", "BAR", "BAZ"] } ``` +% NOTCONSOLE ### Array of objects [foreach-array-objects-ex] @@ -103,6 +106,7 @@ Assume the following document: ] } ``` +% NOTCONSOLE In this case, the `id` field needs to be removed, so the following `foreach` processor is used: @@ -118,6 +122,7 @@ In this case, the `id` field needs to be removed, so the following `foreach` pro } } ``` +% NOTCONSOLE After processing the result is: @@ -133,6 +138,7 @@ After processing the result is: ] } ``` +% NOTCONSOLE For another array of objects example, refer to the [attachment processor documentation](/reference/enrich-processor/attachment.md#attachment-with-arrays). @@ -162,6 +168,7 @@ You can also use the `foreach` processor on object fields. For example, the foll } } ``` +% NOTCONSOLE The following `foreach` processor changes the value of `products.display_name` to uppercase. @@ -177,6 +184,7 @@ The following `foreach` processor changes the value of `products.display_name` t } } ``` +% NOTCONSOLE When run on the document, the `foreach` processor returns: @@ -201,6 +209,7 @@ When run on the document, the `foreach` processor returns: } } ``` +% NOTCONSOLE The following `foreach` processor sets each element’s key to the value of `products.display_name`. If `products.display_name` contains an empty string, the processor deletes the element. @@ -217,6 +226,7 @@ The following `foreach` processor sets each element’s key to the value of `pro } } ``` +% NOTCONSOLE When run on the previous document, the `foreach` processor returns: @@ -236,6 +246,7 @@ When run on the previous document, the `foreach` processor returns: } } ``` +% NOTCONSOLE ### Failure handling [failure-handling-ex] @@ -262,6 +273,7 @@ The wrapped processor can have a `on_failure` definition. For example, the `id` } } ``` +% NOTCONSOLE In this example, if the `remove` processor does fail, then the array elements that have been processed thus far will be updated. diff --git a/docs/reference/enrich-processor/geoip-processor.md b/docs/reference/enrich-processor/geoip-processor.md index 96b8cc9547612..1f107d72e5b90 100644 --- a/docs/reference/enrich-processor/geoip-processor.md +++ b/docs/reference/enrich-processor/geoip-processor.md @@ -93,6 +93,7 @@ Which returns: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term":1/"_primary_term" : $body._primary_term/] Here is an example that uses the default country database and adds the geographical information to the `geo` field based on the `ip` field. Note that this database is downloaded automatically. So this: @@ -137,6 +138,8 @@ returns this: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] + Not all IP addresses find geo information from the database, When this occurs, no `target_field` is inserted into the document. @@ -178,6 +181,7 @@ Which returns: } } ``` +% TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] ### Recognizing Location as a Geopoint [ingest-geoip-mappings-note] diff --git a/docs/reference/enrich-processor/grok-processor.md b/docs/reference/enrich-processor/grok-processor.md index d1d754e099725..672c0ae6c5764 100644 --- a/docs/reference/enrich-processor/grok-processor.md +++ b/docs/reference/enrich-processor/grok-processor.md @@ -83,6 +83,7 @@ This pipeline will insert these named captures as new fields within the document ] } ``` +% TESTRESPONSE[s/2016-11-08T19:43:03.850\+0000/$body.docs.0.doc._ingest.timestamp/] ## Custom Patterns [custom-patterns] @@ -108,6 +109,7 @@ You can add your own patterns to a processor definition under the `pattern_defin ] } ``` +% NOTCONSOLE ## Providing Multiple Match Patterns [trace-match] @@ -166,6 +168,7 @@ response: ] } ``` +% TESTRESPONSE[s/2016-11-08T19:43:03.850\+0000/$body.docs.0.doc._ingest.timestamp/] Both patterns will set the field `pet` with the appropriate match, but what if we want to trace which of our patterns matched and populated our fields? We can do this with the `trace_match` parameter. Here is the output of that same pipeline, but with `"trace_match": true` configured: @@ -190,6 +193,7 @@ Both patterns will set the field `pet` with the appropriate match, but what if w ] } ``` +% TESTRESPONSE[s/2016-11-08T19:43:03.850\+0000/$body.docs.0.doc._ingest.timestamp/] In the above response, you can see that the index of the pattern that matched was `"1"`. This is to say that it was the second (index starts at zero) pattern in `patterns` to match. @@ -214,6 +218,7 @@ The above request will return a response body containing a key-value representat ... } ``` +% NOTCONSOLE By default, the API returns a list of legacy Grok patterns. These legacy patterns predate the [Elastic Common Schema (ECS)](ecs://reference/ecs-field-reference.md) and don’t use ECS field names. To return patterns that extract ECS field names, specify `v1` in the optional `ecs_compatibility` query parameter. @@ -240,6 +245,7 @@ The API returns the following response. ... } ``` +% NOTCONSOLE This can be useful to reference as the built-in patterns change across versions. @@ -270,5 +276,6 @@ PUT _cluster/settings } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/gsub-processor.md b/docs/reference/enrich-processor/gsub-processor.md index 4d6c6939f686d..20328cc518c77 100644 --- a/docs/reference/enrich-processor/gsub-processor.md +++ b/docs/reference/enrich-processor/gsub-processor.md @@ -33,4 +33,5 @@ $$$gsub-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/htmlstrip-processor.md b/docs/reference/enrich-processor/htmlstrip-processor.md index 9adae0eb17224..46221460f540e 100644 --- a/docs/reference/enrich-processor/htmlstrip-processor.md +++ b/docs/reference/enrich-processor/htmlstrip-processor.md @@ -34,4 +34,5 @@ $$$htmlstrip-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/inference-processor.md b/docs/reference/enrich-processor/inference-processor.md index 9674fdc94a4c5..a89dbf52fc0ef 100644 --- a/docs/reference/enrich-processor/inference-processor.md +++ b/docs/reference/enrich-processor/inference-processor.md @@ -54,6 +54,7 @@ If the specified `output_field` already exists in the ingest document, it won’ } } ``` +% NOTCONSOLE ## Configuring multiple inputs [_configuring_multiple_inputs] @@ -76,6 +77,7 @@ The `content` and `title` fields will be read from the incoming document and sen } } ``` +% NOTCONSOLE Selecting the input fields with `input_output` is incompatible with the `target_field` and `field_map` options. @@ -93,6 +95,7 @@ Selecting the input fields with `input_output` is incompatible with the `target_ } } ``` +% NOTCONSOLE ## {{classification-cap}} configuration options [inference-processor-classification-opt] @@ -594,6 +597,7 @@ Refer to [Properties of `tokenizaton`](https://www.elastic.co/docs/api/doc/elast } } ``` +% NOTCONSOLE This configuration specifies a `regression` inference and the results are written to the `my_regression` field contained in the `target_field` results object. The `field_map` configuration maps the field `original_fieldname` from the source document to the field expected by the model. @@ -609,6 +613,7 @@ This configuration specifies a `regression` inference and the results are writte } } ``` +% NOTCONSOLE This configuration specifies a `classification` inference. The number of categories for which the predicted probabilities are reported is 2 (`num_top_classes`). The result is written to the `prediction` field and the top classes to the `probabilities` field. Both fields are contained in the `target_field` results object. @@ -633,6 +638,7 @@ To get the full benefit of aggregating and searching for [{{feat-imp}}](docs-con } } ``` +% NOTCONSOLE The mapping field name for {{feat-imp}} (in the example above, it is `ml.inference.feature_importance`) is compounded as follows: @@ -649,6 +655,7 @@ For example, if you provide a tag `foo` in the definition as you can see below: ... } ``` +% NOTCONSOLE Then, the {{feat-imp}} value is written to the `ml.inference.foo.feature_importance` field. @@ -660,6 +667,7 @@ You can also specify the target field as follows: "target_field": "my_field" } ``` +% NOTCONSOLE In this case, {{feat-imp}} is exposed in the `my_field.foo.feature_importance` field. @@ -694,6 +702,7 @@ PUT _ingest/pipeline/query_helper_pipeline ] } ``` +% TEST[skip: An inference endpoint is required.] 1. The `prompt` field contains the prompt used for the completion task, created with [Painless](docs-content://explore-analyze/scripting/modules-scripting-painless.md). `+ ctx.content` appends the natural language input to the prompt. 2. The ID of the pre-configured {{infer}} endpoint, which utilizes the [`openai` service](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put) with the `completion` task type. @@ -713,6 +722,7 @@ POST _ingest/pipeline/query_helper_pipeline/_simulate ] } ``` +% TEST[skip: An inference processor with an inference endpoint is required.] 1. The natural language query used to generate an {{es}} query within the prompt created by the {{infer}} processor. diff --git a/docs/reference/enrich-processor/ingest-circle-processor.md b/docs/reference/enrich-processor/ingest-circle-processor.md index ef13cc822cee9..b3c00030ce6b0 100644 --- a/docs/reference/enrich-processor/ingest-circle-processor.md +++ b/docs/reference/enrich-processor/ingest-circle-processor.md @@ -72,6 +72,7 @@ PUT circles/_doc/1?pipeline=polygonize_circles GET circles/_doc/1 ``` +% TEST[continued] The response from the above index request: @@ -88,6 +89,7 @@ The response from the above index request: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/] ## Example: Circle defined in GeoJSON [_example_circle_defined_in_geojson] @@ -106,6 +108,7 @@ PUT circles/_doc/2?pipeline=polygonize_circles GET circles/_doc/2 ``` +% TEST[continued] The response from the above index request: @@ -134,6 +137,7 @@ The response from the above index request: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/] ## Notes on Accuracy [circle-processor-notes] diff --git a/docs/reference/enrich-processor/ingest-geo-grid-processor.md b/docs/reference/enrich-processor/ingest-geo-grid-processor.md index f7f8407d455a1..40b00a8aa3bf6 100644 --- a/docs/reference/enrich-processor/ingest-geo-grid-processor.md +++ b/docs/reference/enrich-processor/ingest-geo-grid-processor.md @@ -84,6 +84,7 @@ PUT geocells/_doc/1?pipeline=geotile2shape GET geocells/_doc/1 ``` +% TEST[continued] The response shows how the ingest-processor has replaced the `geocell` field with an indexable `geo_shape`: @@ -106,6 +107,7 @@ The response shows how the ingest-processor has replaced the `geocell` field wit } } ``` +% TESTRESPONSE[s/"_version": \d+/"_version": $body._version/ s/"_seq_no": \d+/"_seq_no": $body._seq_no/ s/"_primary_term": 1/"_primary_term": $body._primary_term/] ![Kibana map with showing the geotile at 4/8/5 and its four child cells](images/geogrid_tile.png "") @@ -122,6 +124,7 @@ PUT geocells/_doc/1?pipeline=geohex2shape GET geocells/_doc/1 ``` +% TEST[continued] The response shows how the ingest-processor has replaced the `geocell` field with an indexable `geo_shape`: @@ -138,6 +141,7 @@ The response shows how the ingest-processor has replaced the `geocell` field wit } } ``` +% TESTRESPONSE[s/"_version": \d+/"_version": $body._version/ s/"_seq_no": \d+/"_seq_no": $body._seq_no/ s/"_primary_term": 1/"_primary_term": $body._primary_term/] ![Kibana map with showing an H3 cell](images/geogrid_h3.png "") @@ -178,6 +182,7 @@ PUT geocells/_doc/1?pipeline=geohex2shape GET geocells/_doc/1 ``` +% TEST[continued] The response from this index request: @@ -214,6 +219,7 @@ The response from this index request: } } ``` +% TESTRESPONSE[s/"_version": \d+/"_version": $body._version/ s/"_seq_no": \d+/"_seq_no": $body._seq_no/ s/"_primary_term": 1/"_primary_term": $body._primary_term/] This additional information will then enable, for example, creating a visualization of the H3 cell, its children and its intersecting non-children cells. diff --git a/docs/reference/enrich-processor/ingest-node-set-security-user-processor.md b/docs/reference/enrich-processor/ingest-node-set-security-user-processor.md index 9ff08cba7763d..d4ee8b757738a 100644 --- a/docs/reference/enrich-processor/ingest-node-set-security-user-processor.md +++ b/docs/reference/enrich-processor/ingest-node-set-security-user-processor.md @@ -39,4 +39,5 @@ The following example adds all user details for the current authenticated user t ] } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/ip-location-processor.md b/docs/reference/enrich-processor/ip-location-processor.md index b85b024d795d0..c5cb8145448b6 100644 --- a/docs/reference/enrich-processor/ip-location-processor.md +++ b/docs/reference/enrich-processor/ip-location-processor.md @@ -93,6 +93,7 @@ Which returns: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term":1/"_primary_term" : $body._primary_term/] Here is an example that uses the default country database and adds the geographical information to the `geo` field based on the `ip` field. Note that this database is downloaded automatically. So this: @@ -137,6 +138,7 @@ returns this: } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] Not all IP addresses find geo information from the database, When this occurs, no `target_field` is inserted into the document. @@ -178,5 +180,6 @@ Which returns: } } ``` +% TESTRESPONSE[s/"_seq_no" : \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] diff --git a/docs/reference/enrich-processor/join-processor.md b/docs/reference/enrich-processor/join-processor.md index 3a58553c5c554..293a989bde156 100644 --- a/docs/reference/enrich-processor/join-processor.md +++ b/docs/reference/enrich-processor/join-processor.md @@ -30,4 +30,5 @@ $$$join-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/json-processor.md b/docs/reference/enrich-processor/json-processor.md index f985f65834834..f6fc26ae9e74a 100644 --- a/docs/reference/enrich-processor/json-processor.md +++ b/docs/reference/enrich-processor/json-processor.md @@ -37,6 +37,7 @@ Suppose you provide this configuration of the `json` processor: } } ``` +% NOTCONSOLE If the following document is processed: @@ -45,6 +46,7 @@ If the following document is processed: "string_source": "{\"foo\": 2000}" } ``` +% NOTCONSOLE after the `json` processor operates on it, it will look like: @@ -56,6 +58,7 @@ after the `json` processor operates on it, it will look like: } } ``` +% NOTCONSOLE If the following configuration is provided, omitting the optional `target_field` setting: @@ -66,6 +69,7 @@ If the following configuration is provided, omitting the optional `target_field` } } ``` +% NOTCONSOLE then after the `json` processor operates on this document: @@ -74,6 +78,7 @@ then after the `json` processor operates on this document: "source_and_target": "{\"foo\": 2000}" } ``` +% NOTCONSOLE it will look like: @@ -84,6 +89,7 @@ it will look like: } } ``` +% NOTCONSOLE 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. diff --git a/docs/reference/enrich-processor/kv-processor.md b/docs/reference/enrich-processor/kv-processor.md index 35950d7108118..445cd21ee5f9c 100644 --- a/docs/reference/enrich-processor/kv-processor.md +++ b/docs/reference/enrich-processor/kv-processor.md @@ -20,6 +20,7 @@ For example, if you have a log message which contains `ip=1.2.3.4 error=REFUSED` } } ``` +% NOTCONSOLE ::::{tip} Using the KV Processor can result in field names that you cannot control. Consider using the [Flattened](/reference/elasticsearch/mapping-reference/flattened.md) data type instead, which maps an entire object as a single field and allows for simple searches over its contents. diff --git a/docs/reference/enrich-processor/lowercase-processor.md b/docs/reference/enrich-processor/lowercase-processor.md index e9d36781821bd..e939f9d2a3027 100644 --- a/docs/reference/enrich-processor/lowercase-processor.md +++ b/docs/reference/enrich-processor/lowercase-processor.md @@ -29,4 +29,5 @@ $$$lowercase-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/network-direction-processor.md b/docs/reference/enrich-processor/network-direction-processor.md index 2c90392e439d5..604510e792e9f 100644 --- a/docs/reference/enrich-processor/network-direction-processor.md +++ b/docs/reference/enrich-processor/network-direction-processor.md @@ -100,4 +100,6 @@ Which produces the following result: ] } ``` +% TESTRESPONSE[s/\.\.\./"_index":"_index","_id":"_id","_version":"-3","_ingest":{"timestamp":$body.docs.0.doc._ingest.timestamp},/] +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/pipeline-processor.md b/docs/reference/enrich-processor/pipeline-processor.md index c4da79bfce30b..8d97a80424d11 100644 --- a/docs/reference/enrich-processor/pipeline-processor.md +++ b/docs/reference/enrich-processor/pipeline-processor.md @@ -28,6 +28,7 @@ $$$pipeline-options$$$ } } ``` +% NOTCONSOLE The name of the current pipeline can be accessed from the `_ingest.pipeline` ingest metadata key. @@ -71,6 +72,7 @@ PUT _ingest/pipeline/pipelineB ] } ``` +% TEST[continued] Now indexing a document while applying the outer pipeline will see the inner pipeline executed from the outer pipeline: @@ -80,6 +82,7 @@ PUT /my-index-000001/_doc/1?pipeline=pipelineB "field": "value" } ``` +% TEST[continued] Response from the index request: @@ -98,6 +101,7 @@ Response from the index request: "_primary_term": 1 } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term" : 1/"_primary_term" : $body._primary_term/] Indexed document: @@ -108,4 +112,5 @@ Indexed document: "outer_pipeline_set": "outer" } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/redact-processor.md b/docs/reference/enrich-processor/redact-processor.md index 49b44538f3737..21ab0a4928e52 100644 --- a/docs/reference/enrich-processor/redact-processor.md +++ b/docs/reference/enrich-processor/redact-processor.md @@ -80,6 +80,7 @@ The document in the response still contains the `message` field but now the IP a ] } ``` +% TESTRESPONSE[s/2023-02-01T16:08:39.419056008Z/$body.docs.0.doc._ingest.timestamp/] The IP address is replaced with the word `client` because that is what is specified in the Grok pattern `%{IP:client}`. The `<` and `>` tokens which surround the pattern name are configurable using the `prefix` and `suffix` options. @@ -135,6 +136,7 @@ In the response both the IP `55.3.244.1` and email address `test@elastic.co` hav ] } ``` +% TESTRESPONSE[s/2023-02-01T16:53:14.560005377Z/$body.docs.0.doc._ingest.timestamp/] ## Custom patterns [redact-custom-patterns] @@ -197,6 +199,7 @@ The username is redacted in the response. ] } ``` +% TESTRESPONSE[s/2023-02-01T16:53:14.560005377Z/$body.docs.0.doc._ingest.timestamp/] ## Grok watchdog [grok-watchdog-redact] diff --git a/docs/reference/enrich-processor/registered-domain-processor.md b/docs/reference/enrich-processor/registered-domain-processor.md index e11ae91b7b4a0..1960dc31cf112 100644 --- a/docs/reference/enrich-processor/registered-domain-processor.md +++ b/docs/reference/enrich-processor/registered-domain-processor.md @@ -72,4 +72,5 @@ Which produces the following result: ] } ``` +% TESTRESPONSE[s/\.\.\./"_index":"_index","_id":"_id","_version":"-3","_ingest":{"timestamp":$body.docs.0.doc._ingest.timestamp},/] diff --git a/docs/reference/enrich-processor/remove-processor.md b/docs/reference/enrich-processor/remove-processor.md index 7201391ffb750..0c5f08b2e2f86 100644 --- a/docs/reference/enrich-processor/remove-processor.md +++ b/docs/reference/enrich-processor/remove-processor.md @@ -31,6 +31,7 @@ Here is an example to remove a single field: } } ``` +% NOTCONSOLE To remove multiple fields, you can use the following query: @@ -41,6 +42,7 @@ To remove multiple fields, you can use the following query: } } ``` +% NOTCONSOLE You can also choose to remove all fields other than a specified list: @@ -51,4 +53,5 @@ You can also choose to remove all fields other than a specified list: } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/rename-processor.md b/docs/reference/enrich-processor/rename-processor.md index 35c93d9094889..c638e5b7d243f 100644 --- a/docs/reference/enrich-processor/rename-processor.md +++ b/docs/reference/enrich-processor/rename-processor.md @@ -31,4 +31,5 @@ $$$rename-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/reroute-processor.md b/docs/reference/enrich-processor/reroute-processor.md index fd9e1ebed369b..7df81749d6c6e 100644 --- a/docs/reference/enrich-processor/reroute-processor.md +++ b/docs/reference/enrich-processor/reroute-processor.md @@ -61,6 +61,7 @@ The client ingesting the document must have permissions to write to the final ta ```js {"type":"security_exception","reason":"action [indices:admin/auto_create] is unauthorized for API key id [8-dt9H8BqGblnY2uSI--] of user [elastic/fleet-server] on indices [logs-foo-default], this action is granted by the index privileges [auto_configure,create_index,manage,all]"} ``` +% NOTCONSOLE ## Configuration options [reroute-options] @@ -92,6 +93,7 @@ Use the `if` option to define conditions for when a document should be rerouted: } } ``` +% NOTCONSOLE ### Fallback values [reroute-fallback-values] @@ -110,5 +112,6 @@ In this example, the processor first attempts to resolve `service.name` for the } } ``` +% NOTCONSOLE If a field reference evaluates to a non-string value, the processor fails. \ No newline at end of file diff --git a/docs/reference/enrich-processor/script-processor.md b/docs/reference/enrich-processor/script-processor.md index bf30543f3dfdf..99a5e50ecccfc 100644 --- a/docs/reference/enrich-processor/script-processor.md +++ b/docs/reference/enrich-processor/script-processor.md @@ -89,6 +89,7 @@ The processor produces: ] } ``` +% TESTRESPONSE[s/\.\.\./"_index":"_index","_id":"_id","_version":"-3","_ingest":{"timestamp":$body.docs.0.doc._ingest.timestamp},/] ## Access metadata fields [script-processor-access-metadata-fields] @@ -142,4 +143,5 @@ The processor changes the document’s `_index` to `fr-catalog` from `generic-in ] } ``` +% TESTRESPONSE[s/\.\.\./"_id":"_id","_version":"-3","_ingest":{"timestamp":$body.docs.0.doc._ingest.timestamp},/] diff --git a/docs/reference/enrich-processor/set-processor.md b/docs/reference/enrich-processor/set-processor.md index 48052f02de8c8..26de961004df6 100644 --- a/docs/reference/enrich-processor/set-processor.md +++ b/docs/reference/enrich-processor/set-processor.md @@ -34,6 +34,7 @@ $$$set-options$$$ } } ``` +% NOTCONSOLE This processor can also be used to copy data from one field to another. For example: @@ -89,6 +90,7 @@ Result: ] } ``` +% TESTRESPONSE[s/2019-03-11T21:54:37.909224Z/$body.docs.0.doc._ingest.timestamp/] This processor can also access array fields using dot notation: @@ -147,6 +149,7 @@ Result: ] } ``` +% TESTRESPONSE[s/2023-05-05T16:04:16.456475214Z/$body.docs.0.doc._ingest.timestamp/] The contents of a field including complex values such as arrays and objects can be copied to another field using `copy_from`: @@ -198,4 +201,5 @@ Result: ] } ``` +% TESTRESPONSE[s/2020-09-30T12:55:17.742795Z/$body.docs.0.doc._ingest.timestamp/] diff --git a/docs/reference/enrich-processor/sort-processor.md b/docs/reference/enrich-processor/sort-processor.md index b5e9cbf0a5df2..fa821a440d92b 100644 --- a/docs/reference/enrich-processor/sort-processor.md +++ b/docs/reference/enrich-processor/sort-processor.md @@ -30,4 +30,5 @@ $$$sort-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/split-processor.md b/docs/reference/enrich-processor/split-processor.md index a063cc3431f58..95d39d56ea463 100644 --- a/docs/reference/enrich-processor/split-processor.md +++ b/docs/reference/enrich-processor/split-processor.md @@ -32,6 +32,7 @@ $$$split-options$$$ } } ``` +% NOTCONSOLE 1. Treat all consecutive whitespace characters as a single separator @@ -47,4 +48,5 @@ If the `preserve_trailing` option is enabled, any trailing empty fields in the i } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/terminate-processor.md b/docs/reference/enrich-processor/terminate-processor.md index 066ee1ae440c2..8421afb808ce2 100644 --- a/docs/reference/enrich-processor/terminate-processor.md +++ b/docs/reference/enrich-processor/terminate-processor.md @@ -29,4 +29,5 @@ $$$terminate-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/trim-processor.md b/docs/reference/enrich-processor/trim-processor.md index 316d1c696b518..18764f0db84c2 100644 --- a/docs/reference/enrich-processor/trim-processor.md +++ b/docs/reference/enrich-processor/trim-processor.md @@ -34,4 +34,5 @@ $$$trim-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/uppercase-processor.md b/docs/reference/enrich-processor/uppercase-processor.md index 382574820e872..e61b86ddc232b 100644 --- a/docs/reference/enrich-processor/uppercase-processor.md +++ b/docs/reference/enrich-processor/uppercase-processor.md @@ -29,4 +29,5 @@ $$$uppercase-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/uri-parts-processor.md b/docs/reference/enrich-processor/uri-parts-processor.md index 354c62effbb25..516ca658e9433 100644 --- a/docs/reference/enrich-processor/uri-parts-processor.md +++ b/docs/reference/enrich-processor/uri-parts-processor.md @@ -41,6 +41,7 @@ Here is an example definition of the URI parts processor: ] } ``` +% NOTCONSOLE When the above processor executes on the following document: @@ -51,6 +52,7 @@ When the above processor executes on the following document: } } ``` +% NOTCONSOLE It produces this result: @@ -72,4 +74,5 @@ It produces this result: } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/urldecode-processor.md b/docs/reference/enrich-processor/urldecode-processor.md index cf74d0266a1bb..3f4dcff9d1eac 100644 --- a/docs/reference/enrich-processor/urldecode-processor.md +++ b/docs/reference/enrich-processor/urldecode-processor.md @@ -29,4 +29,5 @@ $$$urldecode-options$$$ } } ``` +% NOTCONSOLE diff --git a/docs/reference/enrich-processor/user-agent-processor.md b/docs/reference/enrich-processor/user-agent-processor.md index 53590dc1625a7..3d8d1f7a16805 100644 --- a/docs/reference/enrich-processor/user-agent-processor.md +++ b/docs/reference/enrich-processor/user-agent-processor.md @@ -73,6 +73,7 @@ Which returns } } ``` +% TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term": 1/"_primary_term" : $body._primary_term/] ### Using a custom regex file [_using_a_custom_regex_file] diff --git a/docs/reference/query-languages/eql.md b/docs/reference/query-languages/eql.md index f45ff727d1bdd..53ee6c8e8abe1 100644 --- a/docs/reference/query-languages/eql.md +++ b/docs/reference/query-languages/eql.md @@ -39,6 +39,14 @@ While no schema is required to use EQL, we recommend using the [ECS](ecs://refer ## Run an EQL search [run-an-eql-search] + + Use the [EQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-search) to run a [basic EQL query](/reference/query-languages/eql/eql-syntax.md#eql-basic-syntax). ```console @@ -49,6 +57,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] By default, basic EQL queries return the 10 most recent matching events in the `hits.events` property. These hits are sorted by timestamp, converted to milliseconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time), in ascending order. @@ -104,6 +113,10 @@ By default, basic EQL queries return the 10 most recent matching events in the ` } } ``` +% TESTRESPONSE[s/"took": 60/"took": $body.took/] +% TESTRESPONSE[s/"_index": ".ds-my-data-stream-2099.12.07-000001"/"_index": $body.hits.events.0._index/] +% TESTRESPONSE[s/"_id": "OQmfCaduce8zoHT93o4H"/"_id": $body.hits.events.0._id/] +% TESTRESPONSE[s/"_id": "xLkCaj4EujzdNSxfYLbO"/"_id": $body.hits.events.1._id/] Use the `size` parameter to get a smaller or larger set of hits: @@ -116,7 +129,7 @@ GET /my-data-stream/_eql/search "size": 50 } ``` - +% TEST[setup:sec_logs] ## Search for a sequence of events [eql-search-sequence] @@ -132,6 +145,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] The response’s `hits.sequences` property contains the 10 most recent matching sequences. @@ -188,6 +202,11 @@ The response’s `hits.sequences` property contains the 10 most recent matching } } ``` +% TESTRESPONSE[s/ \.\.\.\n/"is_partial": false, "is_running": false, "took": $body.took, "timed_out": false,/] +% TESTRESPONSE[s/"total": \.\.\.,/"total": { "value": 1, "relation": "eq" },/] +% TESTRESPONSE[s/"_index": ".ds-my-data-stream-2099.12.07-000001"/"_index": $body.hits.sequences.0.events.0._index/] +% TESTRESPONSE[s/"_id": "OQmfCaduce8zoHT93o4H"/"_id": $body.hits.sequences.0.events.0._id/] +% TESTRESPONSE[s/"_id": "yDwnGIJouOYGBzP0ZE9n"/"_id": $body.hits.sequences.0.events.1._id/] Use [`with maxspan`](/reference/query-languages/eql/eql-syntax.md#eql-with-maxspan-keywords) to constrain matching sequences to a timespan: @@ -201,6 +220,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] Use `!` to match [missing events](/reference/query-languages/eql/eql-syntax.md#eql-missing-events): events in a sequence that do not meet a condition within a given timespan: @@ -215,6 +235,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] Missing events are indicated in the response as `missing": true`: @@ -276,6 +297,11 @@ Missing events are indicated in the response as `missing": true`: } } ``` +% TESTRESPONSE[s/ \.\.\.\n/"is_partial": false, "is_running": false, "took": $body.took, "timed_out": false,/] +% TESTRESPONSE[s/"total": \.\.\.,/"total": { "value": 1, "relation": "eq" },/] +% TESTRESPONSE[s/"_index": ".ds-my-data-stream-2023.07.04-000001"/"_index": $body.hits.sequences.0.events.0._index/] +% TESTRESPONSE[s/"_id": "AnpTIYkBrVQ2QEgsWg94"/"_id": $body.hits.sequences.0.events.0._id/] +% TESTRESPONSE[s/"_id": "BHpTIYkBrVQ2QEgsWg94"/"_id": $body.hits.sequences.0.events.2._id/] Use the [`by` keyword](/reference/query-languages/eql/eql-syntax.md#eql-by-keyword) to match events that share the same field values: @@ -289,6 +315,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] If a field value should be shared across all events, use the `sequence by` keyword. The following query is equivalent to the previous one. @@ -302,6 +329,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] The `hits.sequences.join_keys` property contains the shared field values. @@ -320,6 +348,9 @@ The `hits.sequences.join_keys` property contains the shared field values. } } ``` +% TESTRESPONSE[s/ \.\.\.\n/"is_partial": false, "is_running": false, "took": $body.took, "timed_out": false,/] +% TESTRESPONSE[s/"hits": \.\.\.,/"hits": { "total": { "value": 1, "relation": "eq" },/] +% TESTRESPONSE[s/"events": \.\.\./"events": $body.hits.sequences.0.events/] Use the [`until` keyword](/reference/query-languages/eql/eql-syntax.md#eql-until-keyword) to specify an expiration event for sequences. Matching sequences must end before this event. @@ -334,6 +365,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] ## Sample chronologically unordered events [eql-search-sample] @@ -567,6 +599,7 @@ GET /my-index*/_eql/search """ } ``` +% TEST[continued] By default, the response’s `hits.sequences` property contains up to 10 samples. Each sample has a set of `join_keys` and an array with one matching event for each of the filters. Events are returned in the order of the filters they match: @@ -693,6 +726,7 @@ By default, the response’s `hits.sequences` property contains up to 10 samples } } ``` +% TESTRESPONSE[skip:Response is illustrative only] 1. The events in the first sample have a value of `doom` for `host`. 2. This event matches the first filter. @@ -714,6 +748,7 @@ GET /my-index*/_eql/search """ } ``` +% TEST[continued] This query will return samples where each of the events shares the same value for `os` or `op_sys`, as well as for `host`. For example: @@ -843,6 +878,7 @@ This query will return samples where each of the events shares the same value fo } } ``` +% TESTRESPONSE[skip:Response is illustrative only] 1. The events in this sample have a value of `doom` for `host` and a value of `redhat` for `os` or `op_sys`. @@ -862,6 +898,7 @@ GET /my-index*/_eql/search """ } ``` +% TEST[continued] 1. Retrieve up to 2 samples per set of join keys. 2. Retrieve up to 20 samples in total. @@ -882,6 +919,7 @@ GET /my-data-stream/_eql/search?filter_path=hits.events._source.@timestamp,hits. """ } ``` +% TEST[setup:sec_logs] The API returns the following response. @@ -939,6 +977,7 @@ GET /my-data-stream/_eql/search?filter_path=-hits.events._source ] } ``` +% TEST[setup:sec_logs] 1. Both full field names and wildcard patterns are accepted. 2. Use the `format` parameter to apply a custom format for the field’s values. @@ -987,6 +1026,11 @@ The response includes values as a flat list in the `fields` section for each hit } } ``` +% TESTRESPONSE[s/ \.\.\.\n/"is_partial": false, "is_running": false, "took": $body.took, "timed_out": false,/] +% TESTRESPONSE[s/"total": \.\.\.,/"total": { "value": 2, "relation": "eq" },/] +% TESTRESPONSE[s/"_index": ".ds-my-data-stream-2099.12.07-000001"/"_index": $body.hits.events.0._index/] +% TESTRESPONSE[s/"_id": "OQmfCaduce8zoHT93o4H"/"_id": $body.hits.events.0._id/] +% TESTRESPONSE[s/ \.\.\.\.\n/$body.hits.events.1/] ## Use runtime fields [eql-use-runtime-fields] @@ -1013,6 +1057,7 @@ GET /my-data-stream/_eql/search?filter_path=-hits.events._source ] } ``` +% TEST[setup:sec_logs] The API returns: @@ -1039,6 +1084,11 @@ The API returns: } } ``` +% TESTRESPONSE[s/ \.\.\.\n/"is_partial": false, "is_running": false, "took": $body.took, "timed_out": false,/] +% TESTRESPONSE[s/"total": \.\.\.,/"total": { "value": 2, "relation": "eq" },/] +% TESTRESPONSE[s/"_index": ".ds-my-data-stream-2099.12.07-000001"/"_index": $body.hits.events.0._index/] +% TESTRESPONSE[s/"_id": "OQmfCaduce8zoHT93o4H"/"_id": $body.hits.events.0._id/] +% TESTRESPONSE[s/ \.\.\.\.\n/$body.hits.events.1/] ## Specify a timestamp or event category field [specify-a-timestamp-or-event-category-field] @@ -1055,6 +1105,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] The event category field must be mapped as a [`keyword`](/reference/elasticsearch/mapping-reference/keyword.md) family field type. The timestamp field should be mapped as a [`date`](/reference/elasticsearch/mapping-reference/date.md) field type. [`date_nanos`](/reference/elasticsearch/mapping-reference/date_nanos.md) timestamp fields are not supported. You cannot use a [`nested`](/reference/elasticsearch/mapping-reference/nested.md) field or the sub-fields of a `nested` field as the timestamp or event category field. @@ -1076,6 +1127,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] ## Filter using Query DSL [eql-search-filter-query-dsl] @@ -1098,6 +1150,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] ## Run an async EQL search [eql-search-async] @@ -1115,6 +1168,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] If the request doesn’t finish within the timeout period, the search becomes async and returns a response that includes: @@ -1134,12 +1188,18 @@ The async search continues to run in the background without blocking other reque "hits": ... } ``` +% TESTRESPONSE[s/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=/$body.id/] +% TESTRESPONSE[s/"is_partial": true/"is_partial": $body.is_partial/] +% TESTRESPONSE[s/"is_running": true/"is_running": $body.is_running/] +% TESTRESPONSE[s/"took": 2000/"took": $body.took/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] To check the progress of an async search, use the [get async EQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-search) with the search ID. Specify how long you’d like for complete results in the `wait_for_completion_timeout` parameter. ```console GET /_eql/search/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=?wait_for_completion_timeout=2s ``` +% TEST[skip: no access to search ID] If the response’s `is_running` value is `false`, the async search has finished. If the `is_partial` value is `false`, the returned search results are complete. @@ -1153,12 +1213,16 @@ If the response’s `is_running` value is `false`, the async search has finished "hits": ... } ``` +% TESTRESPONSE[s/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=/$body.id/] +% TESTRESPONSE[s/"took": 2000/"took": $body.took/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] Another more lightweight way to check the progress of an async search is to use the [get async EQL status API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-get-status) with the search ID. ```console GET /_eql/search/status/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE= ``` +% TEST[skip: no access to search ID] ```console-result { @@ -1169,6 +1233,8 @@ GET /_eql/search/status/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FS "completion_status": 200 } ``` +% TESTRESPONSE[s/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=/$body.id/] +% TESTRESPONSE[s/"expiration_time_in_millis": 1611690295000/"expiration_time_in_millis": $body.expiration_time_in_millis/] ## Change the search retention period [eql-search-store-async-eql-search] @@ -1185,18 +1251,21 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] You can use the [get async EQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-search)'s `keep_alive` parameter to later change the retention period. The new retention period starts after the get request runs. ```console GET /_eql/search/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=?keep_alive=5d ``` +% TEST[skip: no access to search ID] Use the [delete async EQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-search) to manually delete an async EQL search before the `keep_alive` period ends. If the search is still ongoing, {{es}} cancels the search request. ```console DELETE /_eql/search/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE= ``` +% TEST[skip: no access to search ID] ## Store synchronous EQL searches [eql-search-store-sync-eql-search] @@ -1213,6 +1282,7 @@ GET /my-data-stream/_eql/search """ } ``` +% TEST[setup:sec_logs] The response includes a search ID. `is_partial` and `is_running` are `false`, indicating the EQL search was synchronous and returned complete results. @@ -1226,12 +1296,16 @@ The response includes a search ID. `is_partial` and `is_running` are `false`, in "hits": ... } ``` +% TESTRESPONSE[s/FjlmbndxNmJjU0RPdExBTGg0elNOOEEaQk9xSjJBQzBRMldZa1VVQ2pPa01YUToxMDY=/$body.id/] +% TESTRESPONSE[s/"took": 52/"took": $body.took/] +% TESTRESPONSE[s/"hits": \.\.\./"hits": $body.hits/] Use the [get async EQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-search) to get the same results later: ```console GET /_eql/search/FjlmbndxNmJjU0RPdExBTGg0elNOOEEaQk9xSjJBQzBRMldZa1VVQ2pPa01YUToxMDY= ``` +% TEST[skip: no access to search ID] Saved synchronous searches are still subject to the `keep_alive` parameter’s retention period. When this period ends, the search and its results are deleted. @@ -1272,6 +1346,8 @@ PUT /_cluster/settings } } ``` +% TEST[setup:host] +% TEST[s/127.0.0.1:930\d+/\${transport_host}/] To target a data stream or index on a remote cluster, use the `:` syntax. @@ -1283,6 +1359,9 @@ GET /cluster_one:my-data-stream,cluster_two:my-data-stream/_eql/search """ } ``` +% TEST[continued] +% TEST[setup:sec_logs] +% TEST[teardown:data_stream_cleanup] ## EQL circuit breaker settings [eql-circuit-breaker] diff --git a/docs/reference/query-languages/eql/eql-syntax.md b/docs/reference/query-languages/eql/eql-syntax.md index 994b2089d7d6c..887f26cf6bc4a 100644 --- a/docs/reference/query-languages/eql/eql-syntax.md +++ b/docs/reference/query-languages/eql/eql-syntax.md @@ -815,6 +815,7 @@ A data set contains the following `process` events in ascending chronological or { "index" : { "_id": "11" } } { "user": { "name": "root" }, "process": { "name": "cat" }, ...} ``` +% NOTCONSOLE An EQL sequence query searches the data set: diff --git a/docs/reference/query-languages/esql/esql-cross-clusters.md b/docs/reference/query-languages/esql/esql-cross-clusters.md index 762c6b2ab6ae9..105cbd6aa2f01 100644 --- a/docs/reference/query-languages/esql/esql-cross-clusters.md +++ b/docs/reference/query-languages/esql/esql-cross-clusters.md @@ -210,6 +210,8 @@ POST /_query/async?format=json "include_ccs_metadata": true } ``` +% TEST[setup:my_index] +% TEST[s/cluster_one:my-index-000001,cluster_two:my-index//] Which returns: @@ -277,6 +279,7 @@ Which returns: } } ``` +% TEST[skip: cross-cluster testing env not set up] 1. How long the entire search (across all clusters) took, in milliseconds. 2. This section of counters shows all possible cluster search states and how many cluster searches are currently in that state. The clusters can have one of the following statuses: **running**, **successful** (searches on all shards were successful), **skipped** (the search failed on a cluster marked with `skip_unavailable`=`true`), **failed** (the search failed on a cluster marked with `skip_unavailable`=`false`) or **partial** (the search was [interrupted](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) before finishing or has partially failed). @@ -300,6 +303,8 @@ POST /_query/async?format=json "include_ccs_metadata": true } ``` +% TEST[continued] +% TEST[s/cluster_one:my-index\*,cluster_two:logs\*/my-index-000001/] Which returns: @@ -348,6 +353,7 @@ Which returns: } } ``` +% TEST[skip: cross-cluster testing env not set up] 1. This cluster is marked as *skipped*, since there were no matching indices on that cluster. 2. Indicates that no shards were searched (due to not having any matching indices). diff --git a/docs/reference/query-languages/esql/esql-lookup-join.md b/docs/reference/query-languages/esql/esql-lookup-join.md index 7f1eafa60fbcd..31d022db16baf 100644 --- a/docs/reference/query-languages/esql/esql-lookup-join.md +++ b/docs/reference/query-languages/esql/esql-lookup-join.md @@ -77,7 +77,7 @@ First let's create two indices with mappings: `threat_list` and `firewall_logs`. PUT threat_list { "settings": { - "index.mode": "lookup" # The lookup index must use this mode + "index.mode": "lookup" <1> }, "mappings": { "properties": { @@ -89,6 +89,8 @@ PUT threat_list } } ``` +1. The lookup index must use this mode + ```console PUT firewall_logs { diff --git a/docs/reference/query-languages/esql/esql-multivalued-fields.md b/docs/reference/query-languages/esql/esql-multivalued-fields.md index adbe8500b369b..fc9f054d9a701 100644 --- a/docs/reference/query-languages/esql/esql-multivalued-fields.md +++ b/docs/reference/query-languages/esql/esql-multivalued-fields.md @@ -42,6 +42,7 @@ Multivalued fields come back as a JSON array: ] } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] The relative order of values in a multivalued field is undefined. They’ll frequently be in ascending order but don’t rely on that. @@ -90,6 +91,7 @@ And {{esql}} sees that removal: ] } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] But other types, like `long` don’t remove duplicates. @@ -133,6 +135,7 @@ And {{esql}} also sees that: ] } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] This is all at the storage layer. If you store duplicate `long`s and then convert them to strings the duplicates will stay: @@ -159,6 +162,7 @@ POST /_query "query": "FROM mv | EVAL b=TO_STRING(b) | LIMIT 2" } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] ```console-result { @@ -174,6 +178,7 @@ POST /_query ] } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] ## `null` in a list [esql-multivalued-nulls] @@ -191,6 +196,7 @@ POST /_query "query": "FROM mv | LIMIT 1" } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] ```console-result { @@ -204,6 +210,7 @@ POST /_query ] } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] ## Functions [esql-multivalued-fields-functions] @@ -219,6 +226,11 @@ POST /mv/_bulk?refresh { "index" : {} } { "a": 2, "b": 3 } ``` +% TEST[continued] +% TEST[warning:Line 1:16: evaluation of [b + 2] failed, treating result as null. Only first 20 failures recorded.] +% TEST[warning:Line 1:16: java.lang.IllegalArgumentException: single-value function encountered multi-value] +% TEST[warning:Line 1:23: evaluation of [a + b] failed, treating result as null. Only first 20 failures recorded.] +% TEST[warning:Line 1:23: java.lang.IllegalArgumentException: single-value function encountered multi-value] ```console POST /_query @@ -226,6 +238,11 @@ POST /_query "query": "FROM mv | EVAL b + 2, a + b | LIMIT 4" } ``` +% TEST[continued] +% TEST[warning:Line 1:16: evaluation of [b + 2] failed, treating result as null. Only first 20 failures recorded.] +% TEST[warning:Line 1:16: java.lang.IllegalArgumentException: single-value function encountered multi-value] +% TEST[warning:Line 1:23: evaluation of [a + b] failed, treating result as null. Only first 20 failures recorded.] +% TEST[warning:Line 1:23: java.lang.IllegalArgumentException: single-value function encountered multi-value] ```console-result { @@ -243,6 +260,7 @@ POST /_query ] } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] Work around this limitation by converting the field to single value with one of: @@ -260,6 +278,7 @@ POST /_query "query": "FROM mv | EVAL b=MV_MIN(b) | EVAL b + 2, a + b | LIMIT 4" } ``` +% TEST[continued] ```console-result { @@ -277,4 +296,5 @@ POST /_query ] } ``` +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] diff --git a/docs/reference/query-languages/esql/esql-query-log.md b/docs/reference/query-languages/esql/esql-query-log.md index 8f04356da6cd1..e2d479b73cd16 100644 --- a/docs/reference/query-languages/esql/esql-query-log.md +++ b/docs/reference/query-languages/esql/esql-query-log.md @@ -47,6 +47,7 @@ The following is an example of a successful query event in the query log: "elasticsearch.cluster.name": "runTask" } ``` +% NOTCONSOLE The following is an example of a failing query event in the query log: @@ -75,7 +76,7 @@ The following is an example of a failing query event in the query log: "elasticsearch.cluster.name": "runTask" } ``` - +% NOTCONSOLE ## Enable query logging [enable-query-log] diff --git a/docs/reference/query-languages/esql/esql-rest.md b/docs/reference/query-languages/esql/esql-rest.md index ac1c5deab722d..c41990a8688e8 100644 --- a/docs/reference/query-languages/esql/esql-rest.md +++ b/docs/reference/query-languages/esql/esql-rest.md @@ -25,6 +25,7 @@ POST /_query?format=txt "query": "FROM library | KEEP author, name, page_count, release_date | SORT page_count DESC | LIMIT 5" } ``` +% TEST[setup:library] Which returns: @@ -37,7 +38,8 @@ Frank Herbert |Dune |604 |1965-06-01T00:00:00.000Z Alastair Reynolds|Revelation Space |585 |2000-03-15T00:00:00.000Z James S.A. Corey |Leviathan Wakes |561 |2011-06-02T00:00:00.000Z ``` - +% TESTRESPONSE[s/\|/\\|/ s/\+/\\+/] +% TESTRESPONSE[non_json] ### Run the {{esql}} query API in Console [esql-kibana-console] @@ -56,6 +58,7 @@ POST /_query?format=txt """ } ``` +% TEST[setup:library] ### Response formats [esql-rest-format] @@ -65,7 +68,16 @@ For example: ```console POST /_query?format=yaml +{ + "query": """ + FROM library + | KEEP author, name, page_count, release_date + | SORT page_count DESC + | LIMIT 5 + """ +} ``` +% TEST[setup:library] ::::{note} The URL parameter takes precedence over the HTTP headers. If neither is specified then the response is returned in the same format as the request. @@ -128,6 +140,7 @@ POST /_query?format=txt } } ``` +% TEST[setup:library] Which returns: @@ -136,7 +149,8 @@ Which returns: ---------------+------------------------------------+---------------+------------------------ Douglas Adams |The Hitchhiker's Guide to the Galaxy|180 |1979-10-12T00:00:00.000Z ``` - +% TESTRESPONSE[s/\|/\\|/ s/\+/\\+/] +% TESTRESPONSE[non_json] ### Columnar results [esql-rest-columnar] @@ -154,6 +168,7 @@ POST /_query?format=json "columnar": true } ``` +% TEST[setup:library] Which returns: @@ -175,7 +190,7 @@ Which returns: ] } ``` - +% TESTRESPONSE[s/"took": 28/"took": "$body.took"/] ### Returning localized results [esql-locale-param] @@ -197,7 +212,8 @@ POST /_query """ } ``` - +% TEST[setup:library] +% TEST[skip:This can output a warning, and asciidoc doesn't support allowed_warnings] ### Passing parameters to a query [esql-rest-params] @@ -216,6 +232,7 @@ POST /_query """ } ``` +% TEST[setup:library] To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (`?`) in the query string for each of the parameters: @@ -233,6 +250,7 @@ POST /_query "params": [300, "Frank Herbert", 0] } ``` +% TEST[setup:library] The parameters can be named parameters or positional parameters. @@ -252,6 +270,7 @@ POST /_query "params": [{"page_count" : 300}, {"author" : "Frank Herbert"}, {"count" : 0}] } ``` +% TEST[setup:library] Positional parameters use question mark placeholders (`?`) followed by an integer. @@ -269,7 +288,7 @@ POST /_query "params": [300, "Frank Herbert", 0] } ``` - +% TEST[setup:library] ### Running an async {{esql}} query [esql-rest-async-query] @@ -292,6 +311,8 @@ POST /_query/async "wait_for_completion_timeout": "2s" } ``` +% TEST[setup:library] +% TEST[skip:awaitsfix https://github.com/elastic/elasticsearch/issues/104013] If the results are not available within the given timeout period, 2 seconds in this case, no results are returned but rather a response that includes: @@ -306,12 +327,14 @@ The query continues to run in the background without blocking other requests. "is_running": true } ``` +% TEST[skip: no access to query ID - may return response values] To check the progress of an async query, use the [{{esql}} async query get API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-get) with the query ID. Specify how long you’d like to wait for complete results in the `wait_for_completion_timeout` parameter. ```console GET /_query/async/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=?wait_for_completion_timeout=30s ``` +% TEST[skip: no access to query ID - may return response values] If the response’s `is_running` value is `false`, the query has finished and the results are returned, along with the `took` time for the query. @@ -322,12 +345,15 @@ If the response’s `is_running` value is `false`, the query has finished and th "columns": ... } ``` +% TEST[skip: no access to query ID - may return response values] To stop a running async query and return the results computed so far, use the [async stop API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-stop) with the query ID. ```console POST /_query/async/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=/stop ``` +% TEST[skip: no access to query ID - may return response values] + The query will be stopped and the response will contain the results computed so far. The response format is the same as the `get` API. ```console-result @@ -338,6 +364,8 @@ The query will be stopped and the response will contain the results computed so "columns": ... } ``` +% TEST[skip: no access to query ID - may return response values] + This API can be used to retrieve results even if the query has already completed, as long as it's within the `keep_alive` window. The `is_partial` field indicates result completeness. A value of `true` means the results are potentially incomplete. @@ -346,6 +374,7 @@ Use the [{{esql}} async query delete API](https://www.elastic.co/docs/api/doc/el ```console DELETE /_query/async/FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI= ``` +% TEST[skip: no access to query ID] ::::{note} You will also receive the async ID and running status in the `X-Elasticsearch-Async-Id` and `X-Elasticsearch-Async-Is-Running` HTTP headers of the response, respectively. diff --git a/docs/reference/query-languages/esql/esql-search-tutorial.md b/docs/reference/query-languages/esql/esql-search-tutorial.md index 61c1c7b871199..989e375757bda 100644 --- a/docs/reference/query-languages/esql/esql-search-tutorial.md +++ b/docs/reference/query-languages/esql/esql-search-tutorial.md @@ -20,6 +20,7 @@ Want to get started quickly? Run the following command in your terminal to set u ```sh curl -fsSL https://elastic.co/start-local | sh ``` +% NOTCONSOLE ## Running {{esql}} queries diff --git a/docs/reference/query-languages/esql/esql-syntax.md b/docs/reference/query-languages/esql/esql-syntax.md index e00c33db81132..467d52faba39e 100644 --- a/docs/reference/query-languages/esql/esql-syntax.md +++ b/docs/reference/query-languages/esql/esql-syntax.md @@ -161,6 +161,7 @@ FROM library """ } ``` +% TEST[setup:library] You can also use [query parameters](/reference/query-languages/esql/esql-rest.md#esql-rest-params) in function named parameters: @@ -176,4 +177,5 @@ FROM library "params": [300, "Frank Herbert", 2] } ``` +% TEST[setup:library] diff --git a/docs/reference/query-languages/esql/esql-task-management.md b/docs/reference/query-languages/esql/esql-task-management.md index a7351591719e3..e1cc6371ed905 100644 --- a/docs/reference/query-languages/esql/esql-task-management.md +++ b/docs/reference/query-languages/esql/esql-task-management.md @@ -40,6 +40,7 @@ Which returns a list of statuses like this: "headers" : { } } ``` +% NOTCONSOLE 1. The user submitted query. 2. Time the query has been running. diff --git a/docs/reference/query-languages/query-dsl/full-text-filter-tutorial.md b/docs/reference/query-languages/query-dsl/full-text-filter-tutorial.md index bdd8934082532..344bd14942a61 100644 --- a/docs/reference/query-languages/query-dsl/full-text-filter-tutorial.md +++ b/docs/reference/query-languages/query-dsl/full-text-filter-tutorial.md @@ -42,6 +42,7 @@ Create the `cooking_blog` index to get started: ```console PUT /cooking_blog ``` +% TESTSETUP Next, define the mappings for the index: @@ -101,6 +102,7 @@ PUT /cooking_blog/_mapping } } ``` +% TEST 1. `analyzer`: Used for text analysis. If you don't specify it, the `standard` analyzer is used by default for `text` fields. It's included here for demonstration purposes. To know more about analyzers, refer [Anatomy of an analyzer](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/manage-data/data-store/text-analysis/anatomy-of-an-analyzer). 2. `ignore_above`: Prevents indexing values longer than 256 characters in the `keyword` field. This is the default value and it's included here for demonstration purposes. It helps to save disk space and avoid potential issues with Lucene's term byte-length limit. For more information, refer to [ignore_above parameter](/reference/elasticsearch/mapping-reference/ignore-above.md). @@ -130,6 +132,7 @@ POST /cooking_blog/_bulk?refresh=wait_for {"index":{"_id":"5"}} {"title":"Crispy Oven-Fried Chicken","description":"Get that perfect crunch without the deep fryer! This oven-fried chicken recipe delivers crispy, juicy results every time. A healthier take on the classic comfort food.","author":"Maria Rodriguez","date":"2023-05-20","category":"Main Course","tags":["chicken","oven-fried","healthy"],"rating":4.9} ``` +% TEST[continued] ## Perform basic full-text searches [full-text-filter-tutorial-match-query] @@ -153,6 +156,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] 1. By default, the `match` query uses `OR` logic between the resulting tokens. This means it will match documents that contain either "fluffy" or "pancakes", or both, in the description field. @@ -198,6 +202,12 @@ At search time, {{es}} defaults to the analyzer defined in the field mapping. Th } } ``` +% TESTRESPONSE[s/"took": 0/"took": "$body.took"/] +% TESTRESPONSE[s/"total": 1/"total": $body._shards.total/] +% TESTRESPONSE[s/"successful": 1/"successful": $body._shards.successful/] +% TESTRESPONSE[s/"value": 1/"value": $body.hits.total.value/] +% TESTRESPONSE[s/"max_score": 1.8378843/"max_score": $body.hits.max_score/] +% TESTRESPONSE[s/"_score": 1.8378843/"_score": $body.hits.hits.0._score/] 1. `hits`: Contains the total number of matching documents and their relation to the total. 2. `max_score`: The highest relevance score among all matching documents. In this example, there is only one matching document. @@ -225,6 +235,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] ::::{dropdown} Example response ```console-result @@ -247,7 +258,7 @@ GET /cooking_blog/_search } } ``` - +% TESTRESPONSE[s/"took": 0/"took": "$body.took"/] :::: @@ -271,6 +282,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] ## Search across multiple fields [full-text-filter-tutorial-multi-match] @@ -290,6 +302,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] This query searches for "vegetarian curry" across the title, description, and tags fields. Each field is treated with equal importance. @@ -307,6 +320,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] 1. The `^` syntax applies a boost to specific fields: @@ -359,6 +373,9 @@ Learn more about fields and per-field boosting in the [`multi_match` query](/ref } } ``` +% TESTRESPONSE[s/"took": 0/"took": "$body.took"/] +% TESTRESPONSE[s/"_score": 7.546015/"_score": $body.hits.hits.0._score/] +% TESTRESPONSE[s/"max_score": 7.546015/"max_score": $body.hits.max_score/] 1. The title contains "Vegetarian" and "Curry", which matches the search terms. The title field has the highest boost (^3), contributing significantly to this document's relevance score. 2. The description contains "curry" and related terms like "vegetables", further increasing the document's relevance. @@ -391,6 +408,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] 1. Note the use of `category.keyword` here. This refers to the [`keyword`](/reference/elasticsearch/mapping-reference/keyword.md) multi-field of the `category` field, ensuring an exact, case-sensitive match. @@ -420,6 +438,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] 1. `gte`: Greater than or equal to May 1, 2023. 2. `lte`: Less than or equal to May 31, 2023. @@ -440,6 +459,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] 1. The `term` query has zero flexibility. For example, if the `author.keyword` contains words `maria` or `maria rodriguez`, the query will have zero hits due to case sensitivity. @@ -508,6 +528,7 @@ GET /cooking_blog/_search } } ``` +% TEST[continued] 1. `must_not`: Excludes documents that match the specified criteria. This is a powerful tool for filtering out unwanted results. @@ -552,6 +573,7 @@ GET /cooking_blog/_search } } ``` +% TESTRESPONSE[s/"took": 1/"took": "$body.took"/] 1. The title contains "Spicy" and "Curry", matching the should condition. With the default [best_fields](/reference/query-languages/query-dsl/query-dsl-multi-match-query.md#type-best-fields) behavior, this field contributes most to the relevance score. 2. While the description also contains matching terms, only the best matching field's score is used by default. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-distance-feature-query.md b/docs/reference/query-languages/query-dsl/query-dsl-distance-feature-query.md index 3c047d6c96aaf..d3d4c195a14e6 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-distance-feature-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-distance-feature-query.md @@ -43,6 +43,7 @@ To see how you can set up an index for the `distance_feature` query, try the fol } } ``` + % TESTSETUP 2. Index several documents to this index. @@ -78,6 +79,28 @@ To see how you can set up an index for the `distance_feature` query, try the fol The following `bool` search returns documents with a `name` value of `chocolate`. The search also uses the `distance_feature` query to increase the relevance score of documents with a `production_date` value closer to `now`. + + ```console GET /items/_search { diff --git a/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md b/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md index 6cac2464b05c2..d35e3e8f4252a 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md @@ -26,6 +26,7 @@ GET /_search } } ``` +% TEST[setup:my_index] 1. See [Function score](#score-functions) for a list of supported functions. @@ -58,6 +59,7 @@ GET /_search } } ``` +% TEST[setup:my_index] 1. Boost for the whole query. 2. See [Function score](#score-functions) for a list of supported functions. @@ -153,6 +155,7 @@ GET /_search } } ``` +% TEST[setup:my_index] ::::{important} In {{es}}, all document scores are positive 32-bit floating point numbers. @@ -189,6 +192,7 @@ GET /_search } } ``` +% TEST[setup:my_index] Note that unlike the `custom_score` query, the score of the query is multiplied with the result of the script scoring. If you wish to inhibit this, set `"boost_mode": "replace"` @@ -200,6 +204,7 @@ The `weight` score allows you to multiply the score by the provided `weight`. Th ```js "weight" : number ``` +% NOTCONSOLE ## Random [function-random] @@ -226,6 +231,7 @@ GET /_search } } ``` +% TEST[setup:my_index] ## Field Value factor [function-field-value-factor] @@ -249,6 +255,7 @@ GET /_search } } ``` +% TEST[setup:my_index] Which will translate into the following formula for scoring: @@ -308,6 +315,7 @@ To use distance scoring on a query that has numerical fields, the user has to de } } ``` +% NOTCONSOLE 1. The `DECAY_FUNCTION` should be one of `linear`, `exp`, or `gauss`. 2. The specified field must be a numeric, date, or geopoint field. @@ -332,6 +340,7 @@ GET /_search } } ``` +% TEST[setup:my_index] 1. The date format of the origin depends on the [`format`](/reference/elasticsearch/mapping-reference/mapping-date-format.md) defined in your mapping. If you do not define the origin, the current time is used. 2. The `offset` and `decay` parameters are optional. @@ -425,6 +434,7 @@ Example: "multi_value_mode": "avg" } ``` +% NOTCONSOLE @@ -450,6 +460,7 @@ The function for `price` in this case would be } } ``` +% NOTCONSOLE 1. This decay function could also be `linear` or `exp`. @@ -464,6 +475,7 @@ and for `location`: } } ``` +% NOTCONSOLE 1. This decay function could also be `linear` or `exp`. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-geo-bounding-box-query.md b/docs/reference/query-languages/query-dsl/query-dsl-geo-bounding-box-query.md index 99fd7732fbb1a..868571afb55a3 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-geo-bounding-box-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-geo-bounding-box-query.md @@ -65,6 +65,7 @@ PUT /my_geoshapes/_doc/1 } } ``` +% TESTSETUP Use a `geo_bounding_box` filter to match `geo_point` values that intersect a bounding box. To define the box, provide geopoint values for two opposite corners. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-geo-distance-query.md b/docs/reference/query-languages/query-dsl/query-dsl-geo-distance-query.md index 267a8e0ef1c52..f12f6cb693d24 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-geo-distance-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-geo-distance-query.md @@ -65,6 +65,7 @@ PUT /my_geoshapes/_doc/1 } } ``` +% TESTSETUP Use a `geo_distance` filter to match `geo_point` values within a specified distance of another geopoint: diff --git a/docs/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md b/docs/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md index 9eb21e652348d..2871dc7d859c4 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md @@ -49,6 +49,7 @@ PUT /my_locations/_doc/3?refresh "name": "Musée du Louvre" } ``` +% TESTSETUP ## geohash grid [query-dsl-geo-grid-query-geohash] @@ -103,6 +104,7 @@ GET /my_locations/_search } } ``` +% TESTRESPONSE[s/"took" : 10/"took" : $body.took/] We can extract the documents on one of those buckets by executing a geo_grid query using the bucket key with the following syntax: @@ -150,6 +152,7 @@ GET /my_locations/_search } } ``` +% TESTRESPONSE[s/"took" : 1/"took" : $body.took/] ## geotile grid [query-dsl-geo-grid-query-geotile] @@ -205,6 +208,7 @@ GET /my_locations/_search } } ``` +% TESTRESPONSE[s/"took" : 1/"took" : $body.took/] We can extract the documents on one of those buckets by executing a geo_grid query using the bucket key with the following syntax: @@ -252,6 +256,7 @@ GET /my_locations/_search } } ``` +% TESTRESPONSE[s/"took" : 1/"took" : $body.took/] ## geohex grid [query-dsl-geo-grid-query-geohex] @@ -307,6 +312,7 @@ GET /my_locations/_search } } ``` +% TESTRESPONSE[s/"took" : 2/"took" : $body.took/] We can extract the documents on one of those buckets by executing a geo_grid query using the bucket key with the following syntax: @@ -354,5 +360,6 @@ GET /my_locations/_search } } ``` +% TESTRESPONSE[s/"took" : 26/"took" : $body.took/] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-geo-polygon-query.md b/docs/reference/query-languages/query-dsl/query-dsl-geo-polygon-query.md index 57eb679cbdf54..18a7c571cff65 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-geo-polygon-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-geo-polygon-query.md @@ -39,6 +39,7 @@ GET /_search } } ``` +% TEST[warning:Deprecated field [geo_polygon] used, replaced by [[geo_shape] query where polygons are defined in geojson or wkt]] ## Query options [_query_options_2] @@ -81,6 +82,7 @@ GET /_search } } ``` +% TEST[warning:Deprecated field [geo_polygon] used, replaced by [[geo_shape] query where polygons are defined in geojson or wkt]] ### Lat lon as string [_lat_lon_as_string_2] @@ -110,6 +112,7 @@ GET /_search } } ``` +% TEST[warning:Deprecated field [geo_polygon] used, replaced by [[geo_shape] query where polygons are defined in geojson or wkt]] ### Geohash [_geohash_4] @@ -137,6 +140,7 @@ GET /_search } } ``` +% TEST[warning:Deprecated field [geo_polygon] used, replaced by [[geo_shape] query where polygons are defined in geojson or wkt]] ## `geo_point` type [_geo_point_type] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-geo-shape-query.md b/docs/reference/query-languages/query-dsl/query-dsl-geo-shape-query.md index 0a9c1d5bf87e6..c6fff160d9c8c 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-geo-shape-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-geo-shape-query.md @@ -40,6 +40,7 @@ POST /example/_doc?refresh } } ``` +% TESTSETUP The following query will find the point using {{es}}'s `envelope` GeoJSON extension: @@ -87,6 +88,7 @@ PUT /example_points/_doc/1?refresh "location": [13.400544, 52.530286] } ``` +% TEST[continued] Using the same query, the documents with matching `geo_point` fields are returned. @@ -113,6 +115,7 @@ GET /example_points/_search } } ``` +% TEST[continued] ```console-result { @@ -144,6 +147,7 @@ GET /example_points/_search } } ``` +% TESTRESPONSE[s/"took" : 17/"took" : $body.took/] ## Pre-indexed shape [_pre_indexed_shape] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-has-child-query.md b/docs/reference/query-languages/query-dsl/query-dsl-has-child-query.md index 3e0f2e6051aa9..771be904d42f7 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-has-child-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-has-child-query.md @@ -38,6 +38,7 @@ PUT /my-index-000001 } } ``` +% TESTSETUP ### Example query [has-child-query-ex-query] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-has-parent-query.md b/docs/reference/query-languages/query-dsl/query-dsl-has-parent-query.md index 9ae1189ba091b..809d88bdc4d71 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-has-parent-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-has-parent-query.md @@ -39,6 +39,7 @@ PUT /my-index-000001 } } ``` +% TESTSETUP ### Example query [has-parent-query-ex-query] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-knn-query.md b/docs/reference/query-languages/query-dsl/query-dsl-knn-query.md index f94b310b233ac..538db88600fa2 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-knn-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-knn-query.md @@ -47,6 +47,7 @@ PUT my-image-index { "index": { "_id": "3" } } { "image-vector": [15, 11, 23], "file-type": "jpg", "title": "mountain lake lodge" } ``` + % TEST[continued] 2. Run the search using the `knn` query, asking for the top 10 nearest vectors from each shard, and then combine shard results to get the top 3 global results. @@ -63,7 +64,7 @@ PUT my-image-index } } ``` - + % TEST[continued] ## Top-level parameters for `knn` [knn-query-top-level-parameters] @@ -164,6 +165,7 @@ POST my-image-index/_search } } ``` +% TEST[continued] ## Hybrid search with knn query [knn-query-in-hybrid-search] @@ -199,6 +201,7 @@ POST my-image-index/_search } } ``` +% TEST[continued] ## Knn query inside a nested query [knn-query-with-nested-query] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-nested-query.md b/docs/reference/query-languages/query-dsl/query-dsl-nested-query.md index 5e6bbf798d1b6..7c6ab449d143f 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-nested-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-nested-query.md @@ -52,6 +52,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] @@ -175,6 +176,7 @@ PUT /drivers/_doc/2?refresh } } ``` +% TEST[continued] You can now use a multi-level nested query to match documents based on the `make` and `model` fields. @@ -201,6 +203,7 @@ GET /drivers/_search } } ``` +% TEST[continued] The search request returns the following response: @@ -245,6 +248,7 @@ The search request returns the following response: } } ``` +% TESTRESPONSE[s/"took" : 5/"took": $body.took/] ### `must_not` clauses and `nested` queries [must-not-clauses-and-nested-queries] @@ -320,6 +324,7 @@ POST my-index/_search } } ``` +% TEST[s/_search/_search?filter_path=hits.hits/] The search returns: @@ -360,6 +365,7 @@ The search returns: } } ``` +% TESTRESPONSE[s/\.\.\.//] 1. This nested object matches the query. As a result, the search returns the object’s parent document as a hit. 2. This nested object doesn’t match the query. Since another nested object in the same document does match the query, the search still returns the parent document as a hit. @@ -388,6 +394,8 @@ POST my-index/_search } } ``` +% TEST[continued] +% TEST[s/_search/_search?filter_path=hits.hits/] The search returns: @@ -413,6 +421,7 @@ The search returns: } } ``` +% TESTRESPONSE[s/\.\.\.//] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-parent-id-query.md b/docs/reference/query-languages/query-dsl/query-dsl-parent-id-query.md index 655a5d15d49bb..0df12d96fd120 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-parent-id-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-parent-id-query.md @@ -32,6 +32,7 @@ To use the `parent_id` query, your index must include a [join](/reference/elasti } } ``` + % TESTSETUP 2. Index a parent document with an ID of `1`. @@ -62,6 +63,24 @@ To use the `parent_id` query, your index must include a [join](/reference/elasti The following search returns child documents for a parent document with an ID of `1`. + ```console GET /my-index-000001/_search { diff --git a/docs/reference/query-languages/query-dsl/query-dsl-percolate-query.md b/docs/reference/query-languages/query-dsl/query-dsl-percolate-query.md index 7dc42febff15f..3f1163d6e1127 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-percolate-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-percolate-query.md @@ -50,6 +50,7 @@ PUT /my-index-000001/_doc/1?refresh } } ``` +% TEST[continued] Match a document to the registered percolator queries: @@ -66,6 +67,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] The above request will yield the following response: @@ -105,6 +107,7 @@ The above request will yield the following response: } } ``` +% TESTRESPONSE[s/"took": 13,/"took": "$body.took",/] 1. The query with id `1` matches our document. 2. The `_percolator_document_slot` field indicates which document has matched with this query. Useful when percolating multiple document simultaneously. @@ -174,6 +177,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] At index time terms are extracted from the percolator query and the percolator can often determine whether a query matches just by looking at those extracted terms. However, computing scores requires to deserialize each matching query and run it against the percolated document, which is a much more expensive operation. Hence if computing scores is not required the `percolate` query should be wrapped in a `constant_score` query or a `bool` query’s filter clause. @@ -210,6 +214,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] 1. The documents array contains 4 documents that are going to be percolated at the same time. @@ -250,6 +255,7 @@ GET /my-index-000001/_search } } ``` +% TESTRESPONSE[s/"took": 13,/"took": "$body.took",/] 1. The `_percolator_document_slot` indicates that the first, second and last documents specified in the `percolate` query are matching with this query. @@ -271,6 +277,7 @@ PUT /my-index-000001/_doc/2 "message" : "A new bonsai tree in the office" } ``` +% TEST[continued] Index response: @@ -305,6 +312,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] 1. The version is optional, but useful in certain cases. We can ensure that we are trying to percolate the document we just have indexed. A change may be made after we have indexed, and if that is the case the search request would fail with a version conflict error. @@ -333,6 +341,7 @@ PUT /my-index-000001/_doc/3?refresh } } ``` +% TEST[continued] Save another query: @@ -346,6 +355,7 @@ PUT /my-index-000001/_doc/4?refresh } } ``` +% TEST[continued] Execute a search request with the `percolate` query and highlighting enabled: @@ -367,6 +377,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] This will yield the following response. @@ -431,6 +442,7 @@ This will yield the following response. } } ``` +% TESTRESPONSE[s/"took": 7,/"took": "$body.took",/] 1. The terms from each query have been highlighted in the document. @@ -468,6 +480,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] The slightly different response: @@ -518,6 +531,7 @@ The slightly different response: } } ``` +% TESTRESPONSE[s/"took": 13,/"took": "$body.took",/] 1. The highlight fields have been prefixed with the document slot they belong to, in order to know which highlight field belongs to what document. @@ -557,6 +571,7 @@ PUT /my-index-000001/_doc/5?refresh } } ``` +% TEST[continued] ```console GET /my-index-000001/_search @@ -582,6 +597,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] ```console-result { @@ -639,6 +655,7 @@ GET /my-index-000001/_search } } ``` +% TESTRESPONSE[s/"took": 55,/"took": "$body.took",/] 1. The first document matched only the first sub-query. 2. The second document matched only the second sub-query. @@ -679,6 +696,7 @@ GET /my-index-000001/_search } } ``` +% TEST[continued] 1. The `name` parameter will be used to identify which percolator document slots belong to what `percolate` query. @@ -723,6 +741,7 @@ The above search request returns a response similar to this: } } ``` +% TESTRESPONSE[s/"took": 13,/"took": "$body.took",/] 1. The `_percolator_document_slot_query1` percolator slot field indicates that these matched slots are from the `percolate` query with `_name` parameter set to `query1`. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-query-string-query.md b/docs/reference/query-languages/query-dsl/query-dsl-query-string-query.md index 31c3e175c21af..9e2b9ae27e408 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-query-string-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-query-string-query.md @@ -448,6 +448,7 @@ GET /my-index-000001/_search } } ``` +% TEST[setup:my_index] The reserved characters are: `+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /` diff --git a/docs/reference/query-languages/query-dsl/query-dsl-range-query.md b/docs/reference/query-languages/query-dsl/query-dsl-range-query.md index 47f98a080237e..298bf8920e4b0 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-range-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-range-query.md @@ -215,6 +215,7 @@ GET /_search } } ``` +% TEST[continued] 1. Indicates that `date` values use a UTC offset of `+01:00`. 2. With a UTC offset of `+01:00`, {{es}} converts this date to `2019-12-31T23:00:00 UTC`. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-rank-feature-query.md b/docs/reference/query-languages/query-dsl/query-dsl-rank-feature-query.md index ea3b40b42a1b3..16f6fbe617bf5 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-rank-feature-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-rank-feature-query.md @@ -58,6 +58,7 @@ PUT /test } } ``` +% TESTSETUP Index several documents to the `test` index. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-rule-query.md b/docs/reference/query-languages/query-dsl/query-dsl-rule-query.md index 3b017804cb1f5..5ea42221ea62b 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-rule-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-rule-query.md @@ -29,6 +29,35 @@ To use the rule query, you first need a defined set of query rules. Use the [que ## Example request [_example_request_2] + ```console GET /_search { diff --git a/docs/reference/query-languages/query-dsl/query-dsl-script-query.md b/docs/reference/query-languages/query-dsl/query-dsl-script-query.md index 604d20cd3080c..2625bfa72e9c1 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-script-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-script-query.md @@ -41,6 +41,8 @@ GET /_search } } ``` +% TEST[setup:ledger] +% TEST[s/_search/_search?filter_path=hits.hits&sort=amount/] You can achieve the same results in a search query by using runtime fields. Use the [`fields`](/reference/elasticsearch/rest-apis/retrieve-selected-fields.md) parameter on the `_search` API to fetch values as part of the same query: @@ -71,6 +73,8 @@ GET /_search "fields": [{"field": "amount.signed"}] } ``` +% TEST[setup:ledger] +% TEST[s/_search/_search?filter_path=hits.hits.fields&sort=amount.signed:desc/] ## Top-level parameters for `script` [script-top-level-params] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-script-score-query.md b/docs/reference/query-languages/query-dsl/query-dsl-script-score-query.md index 8c8e2ed99ac2b..cd5940e6255ca 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-script-score-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-script-score-query.md @@ -30,7 +30,7 @@ GET /_search } } ``` - +% TEARDOWN ## Top-level parameters for `script_score` [script-score-top-level-params] @@ -88,6 +88,7 @@ We suggest using these predefined functions instead of writing your own. These f "source" : "saturation(doc['my-int'].value, 1)" } ``` +% NOTCONSOLE #### Sigmoid [script-score-sigmoid] @@ -99,6 +100,7 @@ We suggest using these predefined functions instead of writing your own. These f "source" : "sigmoid(doc['my-int'].value, 2, 1)" } ``` +% NOTCONSOLE #### Random score function [random-score-function] @@ -112,6 +114,7 @@ We suggest using these predefined functions instead of writing your own. These f "source" : "randomScore(100, '_seq_no')" } ``` +% NOTCONSOLE If the `fieldName` parameter is omitted, the internal Lucene document ids will be used as a source of randomness. This is very efficient, but unfortunately not reproducible since documents might be renumbered by merges. @@ -120,6 +123,7 @@ If the `fieldName` parameter is omitted, the internal Lucene document ids will b "source" : "randomScore(100)" } ``` +% NOTCONSOLE Note that documents that are within the same shard and have the same value for field will get the same score, so it is usually desirable to use a field that has unique values for all documents across a shard. A good default choice might be to use the `_seq_no` field, whose only drawback is that scores will change if the document is updated since update operations also update the value of the `_seq_no` field. @@ -143,6 +147,7 @@ You can read more about decay functions [here](/reference/query-languages/query- } } ``` +% NOTCONSOLE 1. Using `params` allows to compile the script only once, even if params change. @@ -165,6 +170,7 @@ You can read more about decay functions [here](/reference/query-languages/query- } } ``` +% NOTCONSOLE #### Decay functions for date fields [decay-functions-date-fields] @@ -184,6 +190,7 @@ You can read more about decay functions [here](/reference/query-languages/query- } } ``` +% NOTCONSOLE ::::{note} Decay functions on dates are limited to dates in the default format and default time zone. Also calculations with `now` are not supported. @@ -239,6 +246,7 @@ What you used in `script_score` of the Function Score query, you can copy into t } } ``` +% NOTCONSOLE #### `random_score` [random-score] @@ -258,6 +266,7 @@ Use `randomScore` function as described in [random score function](#random-score } } ``` +% NOTCONSOLE For checking if a document has a missing value, you can use `doc['field'].size() == 0`. For example, this script will use a value `1` if a document doesn’t have a field `field`: @@ -269,6 +278,7 @@ For checking if a document has a missing value, you can use `doc['field'].size() } } ``` +% NOTCONSOLE This table lists how `field_value_factor` modifiers can be implemented through a script: @@ -360,6 +370,7 @@ PUT my-index-000001/_doc/2 POST my-index-000001/_refresh ``` +% TESTSETUP #### Cosine similarity [vector-functions-cosine] @@ -542,6 +553,7 @@ You can check if a document has a value for the field `my_vector` with `doc['my_ ```js "source": "doc['my_vector'].size() == 0 ? 0 : cosineSimilarity(params.queryVector, 'my_vector')" ``` +% NOTCONSOLE #### Accessing vectors directly [vector-functions-accessing-vectors] @@ -597,7 +609,7 @@ GET my-index-000001/_search } } ``` - +% TEST[setup:my_index] #### Bit vectors and vector functions [vector-functions-bit-vectors] @@ -647,6 +659,7 @@ PUT my-index-bit-vectors/_doc/3 POST my-index-bit-vectors/_refresh ``` +% TEST[continued] 1. The number of dimensions or bits for the `bit` vector. 2. This vector represents 5 bytes, or `5 * 8 = 40` bits, which equals the configured dimensions @@ -670,6 +683,7 @@ GET my-index-bit-vectors/_search } } ``` +% TEST[continued] 1. This vector is 40 bits, and thus will compute a bitwise `&` operation with the stored vectors. @@ -692,6 +706,7 @@ GET my-index-bit-vectors/_search } } ``` +% TEST[continued] 1. This vector is 40 individual dimensions, and thus will sum the floating point values using the stored `bit` vector as a mask. @@ -726,6 +741,7 @@ GET /my-index-000001/_explain/0 } } ``` +% TEST[setup:my_index] Note that the `explanation` will be null when using in a normal `_search` request, so having a conditional guard is best practice. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-semantic-query.md b/docs/reference/query-languages/query-dsl/query-dsl-semantic-query.md index 67c262c1ad58b..ac7faf8eb17bb 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-semantic-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-semantic-query.md @@ -29,6 +29,7 @@ GET my-index-000001/_search } } ``` +% TEST[skip: Requires inference endpoints] ## Top-level parameters for `semantic` [semantic-query-params] @@ -73,6 +74,7 @@ POST my-index/_search } } ``` +% TEST[skip: Requires inference endpoints] 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: @@ -108,4 +110,5 @@ GET my-index/_search } } ``` +% TEST[skip: Requires inference endpoints] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-shape-query.md b/docs/reference/query-languages/query-dsl/query-dsl-shape-query.md index d94c012981c4c..09dcd0e36d2a8 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-shape-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-shape-query.md @@ -40,6 +40,7 @@ PUT /example/_doc/1?refresh=wait_for } } ``` +% TESTSETUP The following query will find the point using the Elasticsearch’s `envelope` GeoJSON extension: diff --git a/docs/reference/query-languages/query-dsl/query-dsl-sparse-vector-query.md b/docs/reference/query-languages/query-dsl/query-dsl-sparse-vector-query.md index cdc2613a3aa24..a2d46b006e99f 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-sparse-vector-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-sparse-vector-query.md @@ -31,6 +31,7 @@ GET _search } } ``` +% TEST[skip: Requires inference] ## Example request using precomputed vectors [_example_request_using_precomputed_vectors] @@ -46,6 +47,7 @@ GET _search } } ``` +% TEST[skip: TBD] ## Top level parameters for `sparse_vector` [sparse-vector-field-params] @@ -109,6 +111,7 @@ GET my-index/_search } } ``` +% TEST[skip: Requires inference] Multiple `sparse_vector` queries can be combined with each other or other query types. This can be achieved by wrapping them in [boolean query clauses](/reference/query-languages/query-dsl/query-dsl-bool-query.md) and using linear boosting: @@ -149,6 +152,7 @@ GET my-index/_search } } ``` +% TEST[skip: Requires inference] This can also be achieved using [reciprocal rank fusion (RRF)](/reference/elasticsearch/rest-apis/reciprocal-rank-fusion.md), through an [`rrf` retriever](/reference/elasticsearch/rest-apis/retrievers/rrf-retriever.md) with multiple [`standard` retrievers](/reference/elasticsearch/rest-apis/retrievers/standard-retriever.md). @@ -202,6 +206,7 @@ GET my-index/_search } } ``` +% TEST[skip: Requires inference] ## Example ELSER query with pruning configuration and rescore [sparse-vector-query-with-pruning-config-and-rescore-example] @@ -246,6 +251,7 @@ GET my-index/_search } } ``` +% TEST[skip: Requires inference] ::::{note} When performing [cross-cluster search](docs-content://solutions/search/cross-cluster-search.md), inference is performed on the local cluster. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-term-query.md b/docs/reference/query-languages/query-dsl/query-dsl-term-query.md index f19a48ef86009..91b647b1ac1d5 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-term-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-term-query.md @@ -102,6 +102,7 @@ To see the difference in search results, try the following example. "full_text": "Quick Brown Foxes!" } ``` + % TEST[continued] Because `full_text` is a `text` field, {{es}} changes `Quick Brown Foxes!` to `[quick, brown, fox]` during analysis. @@ -117,6 +118,7 @@ To see the difference in search results, try the following example. } } ``` + % TEST[continued] Because the `full_text` field no longer contains the **exact** term `Quick Brown Foxes!`, the `term` query search returns no results. @@ -132,6 +134,7 @@ To see the difference in search results, try the following example. } } ``` + % TEST[continued] Unlike the `term` query, the `match` query analyzes your provided search term, `Quick Brown Foxes!`, before performing a search. The `match` query then returns any documents containing the `quick`, `brown`, or `fox` tokens in the `full_text` field. @@ -166,6 +169,7 @@ To see the difference in search results, try the following example. } } ``` + % TESTRESPONSE[s/"took" : 1/"took" : $body.took/] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-terms-query.md b/docs/reference/query-languages/query-dsl/query-dsl-terms-query.md index a812577ea9a49..60534ad4ef4d6 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-terms-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-terms-query.md @@ -120,6 +120,7 @@ To see how terms lookup works, try the following example. "color": ["blue", "green"] } ``` + % TEST[continued] 3. Index another document with an ID of 2 and value of `blue` in the `color` field. @@ -129,6 +130,7 @@ To see how terms lookup works, try the following example. "color": "blue" } ``` + % TEST[continued] 4. Use the `terms` query with terms lookup parameters to find documents containing one or more of the same terms as document 2. Include the `pretty` parameter so the response is more readable. @@ -146,6 +148,7 @@ To see how terms lookup works, try the following example. } } ``` + % TEST[continued] Because document 2 and document 1 both contain `blue` as a value in the `color` field, {{es}} returns both documents. @@ -189,6 +192,7 @@ To see how terms lookup works, try the following example. } } ``` + % TESTRESPONSE[s/"took" : 17/"took" : $body.took/] diff --git a/docs/reference/query-languages/query-dsl/query-dsl-terms-set-query.md b/docs/reference/query-languages/query-dsl/query-dsl-terms-set-query.md index 29c2eeb0c8c12..4a3cb367a881b 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-terms-set-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-terms-set-query.md @@ -46,6 +46,7 @@ To see how you can set up an index for the `terms_set` query, try the following } } ``` + % TESTSETUP 2. Index a document with an ID of `1` and the following values: @@ -64,6 +65,7 @@ To see how you can set up an index for the `terms_set` query, try the following } ``` + 3. Index another document with an ID of `2` and the following values: * `Jason Response` in the `name` field. @@ -93,6 +95,28 @@ The following search returns documents where the `programming_languages` field c The `minimum_should_match_field` is `required_matches`. This means the number of matching terms required is `2`, the value of the `required_matches` field. + + ```console GET /job-candidates/_search { diff --git a/docs/reference/query-languages/query-dsl/query-dsl-text-expansion-query.md b/docs/reference/query-languages/query-dsl/query-dsl-text-expansion-query.md index a45f6bb2dedf5..c7483836eef44 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-text-expansion-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-text-expansion-query.md @@ -39,6 +39,7 @@ GET _search } } ``` +% TEST[skip: TBD] ## Top level parameters for `text_expansion` [text-expansion-query-params] @@ -92,6 +93,7 @@ GET my-index/_search } } ``` +% TEST[skip: TBD] Multiple `text_expansion` queries can be combined with each other or other query types. This can be achieved by wrapping them in [boolean query clauses](/reference/query-languages/query-dsl/query-dsl-bool-query.md) and using linear boosting: @@ -134,6 +136,7 @@ GET my-index/_search } } ``` +% TEST[skip: TBD] This can also be achieved using [reciprocal rank fusion (RRF)](/reference/elasticsearch/rest-apis/reciprocal-rank-fusion.md), through an [`rrf` retriever](/reference/elasticsearch/rest-apis/retrievers/rrf-retriever.md) with multiple [`standard` retrievers](/reference/elasticsearch/rest-apis/retrievers/standard-retriever.md). @@ -187,6 +190,7 @@ GET my-index/_search } } ``` +% TEST[skip: TBD] ## Example ELSER query with pruning configuration and rescore [text-expansion-query-with-pruning-config-and-rescore-example] @@ -235,6 +239,7 @@ GET my-index/_search } } ``` +% TEST[skip: TBD] ::::{note} Depending on your data, the text expansion query may be faster with `track_total_hits: false`. diff --git a/docs/reference/query-languages/query-dsl/query-dsl-weighted-tokens-query.md b/docs/reference/query-languages/query-dsl/query-dsl-weighted-tokens-query.md index 3db7b2922f335..9b38b3dc338df 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-weighted-tokens-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-weighted-tokens-query.md @@ -43,6 +43,7 @@ POST _search } } ``` +% TEST[skip: TBD] ## Top level parameters for `weighted_token` [weighted-token-query-params] @@ -111,4 +112,5 @@ GET my-index/_search } } ``` +% TEST[skip: TBD] diff --git a/docs/reference/query-languages/query-dsl/regexp-syntax.md b/docs/reference/query-languages/query-dsl/regexp-syntax.md index d52869071324b..8fe2b713982d8 100644 --- a/docs/reference/query-languages/query-dsl/regexp-syntax.md +++ b/docs/reference/query-languages/query-dsl/regexp-syntax.md @@ -56,6 +56,7 @@ GET my-index-000001/_search } } ``` +% TEST[continued] :::: diff --git a/docs/reference/query-languages/sql/sql-async.md b/docs/reference/query-languages/sql/sql-async.md index 9eb78f0a59189..e5c62ebb892dd 100644 --- a/docs/reference/query-languages/sql/sql-async.md +++ b/docs/reference/query-languages/sql/sql-async.md @@ -22,6 +22,7 @@ POST _sql?format=json "fetch_size": 5 } ``` +% TEST[setup:library] If the search doesn’t finish within this period, the search becomes async. The API returns: @@ -39,12 +40,17 @@ For CSV, TSV, and TXT responses, the API returns these values in the respective "rows": [ ] } ``` +% TESTRESPONSE[skip:waiting on https://github.com/elastic/elasticsearch/issues/106158] +% TESTRESPONSE[s/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=/$body.id/] +% TESTRESPONSE[s/"is_partial": true/"is_partial": $body.is_partial/] +% TESTRESPONSE[s/"is_running": true/"is_running": $body.is_running/] To check the progress of an async search, use the search ID with the [get async SQL search status API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-get-async-status). ```console GET _sql/async/status/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU= ``` +% TEST[skip: no access to search ID] If `is_running` and `is_partial` are `false`, the async search has finished with complete results. @@ -57,13 +63,16 @@ If `is_running` and `is_partial` are `false`, the async search has finished with "completion_status": 200 } ``` +% TESTRESPONSE[skip:waiting on https://github.com/elastic/elasticsearch/issues/106158] +% TESTRESPONSE[s/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=/$body.id/] +% TESTRESPONSE[s/"expiration_time_in_millis": 1611690295000/"expiration_time_in_millis": $body.expiration_time_in_millis/] To get the results, use the search ID with the [get async SQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-get-async). If the search is still running, specify how long you’d like to wait using `wait_for_completion_timeout`. You can also specify the response `format`. ```console GET _sql/async/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=?wait_for_completion_timeout=2s&format=json ``` - +% TEST[skip: no access to search ID] ## Change the search retention period [sql-async-retention] @@ -78,19 +87,21 @@ POST _sql?format=json "fetch_size": 5 } ``` +% TEST[setup:library] You can use the get async SQL search API’s `keep_alive` parameter to later change the retention period. The new period starts after the request runs. ```console GET _sql/async/FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=?keep_alive=5d&wait_for_completion_timeout=2s&format=json ``` +% TEST[skip: no access to search ID] Use the [delete async SQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-delete-async) to delete an async search before the `keep_alive` period ends. If the search is still running, {{es}} cancels it. ```console DELETE _sql/async/delete/FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI= ``` - +% TEST[skip: no access to search ID] ## Store synchronous SQL searches [sql-store-searches] @@ -105,6 +116,8 @@ POST _sql?format=json "fetch_size": 5 } ``` +% TEST[skip:waiting on https://github.com/elastic/elasticsearch/issues/106158] +% TEST[setup:library] If `is_partial` and `is_running` are `false`, the search was synchronous and returned complete results. @@ -118,6 +131,11 @@ If `is_partial` and `is_running` are `false`, the search was synchronous and ret "cursor": ... } ``` +% TESTRESPONSE[skip:waiting on https://github.com/elastic/elasticsearch/issues/106158] +% TESTRESPONSE[s/Fnc5UllQdUVWU0NxRFNMbWxNYXplaFEaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQTo0NzA=/$body.id/] +% TESTRESPONSE[s/"rows": \.\.\./"rows": $body.rows/] +% TESTRESPONSE[s/"columns": \.\.\./"columns": $body.columns/] +% TESTRESPONSE[s/"cursor": \.\.\./"cursor": $body.cursor/] You can get the same results later using the search ID with the [get async SQL search API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-get-async). diff --git a/docs/reference/query-languages/sql/sql-data-types.md b/docs/reference/query-languages/sql/sql-data-types.md index 07685ea323a91..c740b94c4ab0d 100644 --- a/docs/reference/query-languages/sql/sql-data-types.md +++ b/docs/reference/query-languages/sql/sql-data-types.md @@ -96,6 +96,7 @@ Consider the following `string` mapping: } } ``` +% NOTCONSOLE The following SQL query: diff --git a/docs/reference/query-languages/sql/sql-getting-started.md b/docs/reference/query-languages/sql/sql-getting-started.md index 44d2b591cc9d5..0a262ebf0cd8c 100644 --- a/docs/reference/query-languages/sql/sql-getting-started.md +++ b/docs/reference/query-languages/sql/sql-getting-started.md @@ -31,6 +31,7 @@ POST /_sql?format=txt "query": "SELECT * FROM library WHERE release_date < '2000-01-01'" } ``` +% TEST[continued] Which should return something along the lines of: @@ -40,6 +41,8 @@ Which should return something along the lines of: Dan Simmons |Hyperion |482 |1989-05-26T00:00:00.000Z Frank Herbert |Dune |604 |1965-06-01T00:00:00.000Z ``` +% TESTRESPONSE[s/\|/\\|/ s/\+/\\+/] +% TESTRESPONSE[non_json] You can also use the [*SQL CLI*](sql-cli.md). There is a script to start it shipped in the Elasticsearch `bin` directory: diff --git a/docs/reference/query-languages/sql/sql-pagination.md b/docs/reference/query-languages/sql/sql-pagination.md index 8de8136e69be4..e86670a0cc6d2 100644 --- a/docs/reference/query-languages/sql/sql-pagination.md +++ b/docs/reference/query-languages/sql/sql-pagination.md @@ -18,6 +18,8 @@ POST /_sql?format=json "cursor": "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=" } ``` +% TEST[setup:library] +% TEST[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f\/\/\/w8=/$body.cursor/] Which looks like: @@ -33,6 +35,7 @@ Which looks like: "cursor" : "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWODRMaXBUaVlRN21iTlRyWHZWYUdrdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl9f///w8=" } ``` +% TESTRESPONSE[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWODRMaXBUaVlRN21iTlRyWHZWYUdrdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl9f\/\/\/w8=/$body.cursor/] Note that the `columns` object is only part of the first page. @@ -46,6 +49,8 @@ POST /_sql/close "cursor": "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=" } ``` +% TEST[continued] +% TEST[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f\/\/\/w8=/$body.cursor/] Which will like return the diff --git a/docs/reference/query-languages/sql/sql-rest-columnar.md b/docs/reference/query-languages/sql/sql-rest-columnar.md index 1ed024231623f..1b66c656058f4 100644 --- a/docs/reference/query-languages/sql/sql-rest-columnar.md +++ b/docs/reference/query-languages/sql/sql-rest-columnar.md @@ -22,6 +22,7 @@ POST /_sql?format=json "columnar": true } ``` +% TEST[setup:library] Which returns: @@ -42,6 +43,7 @@ Which returns: "cursor": "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl+v///w8=" } ``` +% TESTRESPONSE[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl\+v\/\/\/w8=/$body.cursor/] Any subsequent calls using a `cursor` still have to contain the `columnar` parameter to preserve the orientation, meaning the initial query will not *remember* the columnar option. @@ -52,6 +54,8 @@ POST /_sql?format=json "columnar": true } ``` +% TEST[continued] +% TEST[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl\+v\/\/\/w8=/$body.cursor/] Which looks like: @@ -66,4 +70,4 @@ Which looks like: "cursor": "46ToAwFzQERYRjFaWEo1UVc1a1JtVjBZMmdCQUFBQUFBQUFBQUVXWjBaNlFXbzNOV0pVY21Wa1NUZDJhV2t3V2xwblp3PT3/////DwQBZgZhdXRob3IBBHRleHQAAAFmBG5hbWUBBHRleHQAAAFmCnBhZ2VfY291bnQBBGxvbmcBAAFmDHJlbGVhc2VfZGF0ZQEIZGF0ZXRpbWUBAAEP" } ``` - +% TESTRESPONSE[s/46ToAwFzQERYRjFaWEo1UVc1a1JtVjBZMmdCQUFBQUFBQUFBQUVXWjBaNlFXbzNOV0pVY21Wa1NUZDJhV2t3V2xwblp3PT3\/\/\/\/\wQBZgZhdXRob3IBBHRleHQAAAFmBG5hbWUBBHRleHQAAAFmCnBhZ2VfY291bnQBBGxvbmcBAAFmDHJlbGVhc2VfZGF0ZQEIZGF0ZXRpbWUBAAEP/$body.cursor/] diff --git a/docs/reference/query-languages/sql/sql-rest-filtering.md b/docs/reference/query-languages/sql/sql-rest-filtering.md index d479a4f6ef4b3..ed4cd64fb0ab8 100644 --- a/docs/reference/query-languages/sql/sql-rest-filtering.md +++ b/docs/reference/query-languages/sql/sql-rest-filtering.md @@ -27,6 +27,7 @@ POST /_sql?format=txt "fetch_size": 5 } ``` +% TEST[setup:library] Which returns: @@ -35,6 +36,8 @@ Which returns: ---------------+------------------------------------+---------------+------------------------ Douglas Adams |The Hitchhiker's Guide to the Galaxy|180 |1979-10-12T00:00:00.000Z ``` +% TESTRESPONSE[s/\|/\\|/ s/\+/\\+/] +% TESTRESPONSE[non_json] ::::{tip} A useful and less obvious usage for standard Query DSL filtering is to search documents by a specific [routing key](elasticsearch://reference/elasticsearch/rest-apis/search-shard-routing.md#search-routing). Because Elasticsearch SQL does not support a `routing` parameter, one can specify a [`terms` filter for the `_routing` field](elasticsearch://reference/elasticsearch/mapping-reference/mapping-routing-field.md) instead: @@ -50,7 +53,7 @@ POST /_sql?format=txt } } ``` - +% TEST[setup:library] :::: diff --git a/docs/reference/query-languages/sql/sql-rest-format.md b/docs/reference/query-languages/sql/sql-rest-format.md index 78fefa9228a30..ad75879050c2f 100644 --- a/docs/reference/query-languages/sql/sql-rest-format.md +++ b/docs/reference/query-languages/sql/sql-rest-format.md @@ -44,6 +44,7 @@ POST /_sql?format=csv "fetch_size": 5 } ``` +% TEST[setup:library] which returns: @@ -55,6 +56,7 @@ Frank Herbert,Dune,604,1965-06-01T00:00:00.000Z Alastair Reynolds,Revelation Space,585,2000-03-15T00:00:00.000Z James S.A. Corey,Leviathan Wakes,561,2011-06-02T00:00:00.000Z ``` +% TESTRESPONSE[non_json] or: @@ -65,6 +67,7 @@ POST /_sql?format=csv&delimiter=%3b "fetch_size": 5 } ``` +% TEST[setup:library] which returns: @@ -76,7 +79,7 @@ Frank Herbert;Dune;604;1965-06-01T00:00:00.000Z Alastair Reynolds;Revelation Space;585;2000-03-15T00:00:00.000Z James S.A. Corey;Leviathan Wakes;561;2011-06-02T00:00:00.000Z ``` - +% TESTRESPONSE[non_json] ## JSON [_json] @@ -87,6 +90,7 @@ POST /_sql?format=json "fetch_size": 5 } ``` +% TEST[setup:library] Which returns: @@ -108,7 +112,7 @@ Which returns: "cursor": "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl+v///w8=" } ``` - +% TESTRESPONSE[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl\+v\/\/\/w8=/$body.cursor/] ## TSV [_tsv] @@ -119,6 +123,7 @@ POST /_sql?format=tsv "fetch_size": 5 } ``` +% TEST[setup:library] Which returns: @@ -130,7 +135,8 @@ Frank Herbert Dune 604 1965-06-01T00:00:00.000Z Alastair Reynolds Revelation Space 585 2000-03-15T00:00:00.000Z James S.A. Corey Leviathan Wakes 561 2011-06-02T00:00:00.000Z ``` - +% TESTRESPONSE[s/\t/ /] +% TESTRESPONSE[non_json] ## TXT [_txt] @@ -141,6 +147,7 @@ POST /_sql?format=txt "fetch_size": 5 } ``` +% TEST[setup:library] Which returns: @@ -153,7 +160,8 @@ Frank Herbert |Dune |604 |1965-06-01T00:00:00.000Z Alastair Reynolds|Revelation Space |585 |2000-03-15T00:00:00.000Z James S.A. Corey |Leviathan Wakes |561 |2011-06-02T00:00:00.000Z ``` - +% TESTRESPONSE[s/\|/\\|/ s/\+/\\+/] +% TESTRESPONSE[non_json] ## YAML [_yaml] @@ -164,6 +172,7 @@ POST /_sql?format=yaml "fetch_size": 5 } ``` +% TEST[setup:library] Which returns: @@ -200,5 +209,5 @@ rows: - "2011-06-02T00:00:00.000Z" cursor: "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl+v///w8=" ``` - +% TESTRESPONSE[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl\+v\/\/\/w8=/$body.cursor/] diff --git a/docs/reference/query-languages/sql/sql-rest-overview.md b/docs/reference/query-languages/sql/sql-rest-overview.md index 3b54340f78a06..ddb82b9a51b23 100644 --- a/docs/reference/query-languages/sql/sql-rest-overview.md +++ b/docs/reference/query-languages/sql/sql-rest-overview.md @@ -18,6 +18,7 @@ POST /_sql?format=txt "query": "SELECT * FROM library ORDER BY page_count DESC LIMIT 5" } ``` +% TEST[setup:library] Which returns: @@ -30,6 +31,8 @@ Frank Herbert |Dune |604 |1965-06-01T00:00:00.000Z Alastair Reynolds|Revelation Space |585 |2000-03-15T00:00:00.000Z James S.A. Corey |Leviathan Wakes |561 |2011-06-02T00:00:00.000Z ``` +% TESTRESPONSE[s/\|/\\|/ s/\+/\\+/] +% TESTRESPONSE[non_json] ::::{admonition} Using Kibana Console :class: tip diff --git a/docs/reference/query-languages/sql/sql-rest-params.md b/docs/reference/query-languages/sql/sql-rest-params.md index 875316dddaacb..bea4bc48588d8 100644 --- a/docs/reference/query-languages/sql/sql-rest-params.md +++ b/docs/reference/query-languages/sql/sql-rest-params.md @@ -15,19 +15,21 @@ Using values in a query condition, for example, or in a `HAVING` statement can b ```console POST /_sql?format=txt { - "query": "SELECT YEAR(release_date) AS year FROM library WHERE page_count > 300 AND author = 'Frank Herbert' GROUP BY year HAVING COUNT(*) > 0" + "query": "SELECT YEAR(release_date) AS year FROM library WHERE page_count > 300 AND author = 'Frank Herbert' GROUP BY year HAVING COUNT(*) > 0" } ``` +% TEST[setup:library] or it can be done by extracting the values in a separate list of parameters and using question mark placeholders (`?`) in the query string: ```console POST /_sql?format=txt { - "query": "SELECT YEAR(release_date) AS year FROM library WHERE page_count > ? AND author = ? GROUP BY year HAVING COUNT(*) > ?", - "params": [300, "Frank Herbert", 0] + "query": "SELECT YEAR(release_date) AS year FROM library WHERE page_count > ? AND author = ? GROUP BY year HAVING COUNT(*) > ?", + "params": [300, "Frank Herbert", 0] } ``` +% TEST[setup:library] ::::{important} The recommended way of passing values to a query is with question mark placeholders, to avoid any attempts of hacking or SQL injection. diff --git a/docs/reference/query-languages/sql/sql-runtime-fields.md b/docs/reference/query-languages/sql/sql-runtime-fields.md index 72d400e4baee0..c7f5284914a6a 100644 --- a/docs/reference/query-languages/sql/sql-runtime-fields.md +++ b/docs/reference/query-languages/sql/sql-runtime-fields.md @@ -30,6 +30,7 @@ POST _sql?format=txt """ } ``` +% TEST[setup:library] The API returns: @@ -38,4 +39,4 @@ The API returns: ---------------+---------------+---------------+------------------------+------------------- Frank Herbert |Dune |604 |1965-06-01T00:00:00.000Z|TUESDAY ``` - +% TESTRESPONSE[non_json] diff --git a/docs/reference/query-languages/sql/sql-translate.md b/docs/reference/query-languages/sql/sql-translate.md index 422eb4fc96c2d..034f91fe6f291 100644 --- a/docs/reference/query-languages/sql/sql-translate.md +++ b/docs/reference/query-languages/sql/sql-translate.md @@ -19,6 +19,7 @@ POST /_sql/translate "fetch_size": 10 } ``` +% TEST[setup:library] Which returns: diff --git a/docs/reference/scripting-languages/painless/brief-painless-walkthrough.md b/docs/reference/scripting-languages/painless/brief-painless-walkthrough.md index 2a1421b82305c..a711b4c7ad07a 100644 --- a/docs/reference/scripting-languages/painless/brief-painless-walkthrough.md +++ b/docs/reference/scripting-languages/painless/brief-painless-walkthrough.md @@ -34,7 +34,7 @@ PUT hockey/_bulk?refresh {"index":{"_id":11}} {"first":"joe","last":"colborne","goals":[3,18,13],"assists":[6,20,24],"gp":[26,67,82],"born":"1990/01/30"} ``` - +% TESTSETUP ## Accessing Doc Values from Painless [_accessing_doc_values_from_painless] diff --git a/docs/reference/scripting-languages/painless/painless-api-examples.md b/docs/reference/scripting-languages/painless/painless-api-examples.md index b95e9f6b2dbe1..05a696c73cb3b 100644 --- a/docs/reference/scripting-languages/painless/painless-api-examples.md +++ b/docs/reference/scripting-languages/painless/painless-api-examples.md @@ -231,7 +231,7 @@ POST /_scripts/painless/_execute } } ``` - +% TEST[continued] ### Response [_response_2] @@ -283,7 +283,7 @@ POST /_scripts/painless/_execute } } ``` - +% TEST[continued] ### Response [_response_3] @@ -353,6 +353,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] Because *Dune* was published in 1965, the result returns as `true`: @@ -387,6 +388,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] Because `Frank` is five characters, the response returns `false` for the script valuation: @@ -460,6 +462,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] 1. Eight hours, represented in milliseconds 2. Incredibly fast writing from Robert A. Heinlein @@ -533,6 +536,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] The result includes the calculated voltage, which was determined by multiplying the original value of `5.6` by `1.7`: @@ -587,6 +591,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] Because you’re working with a geo-point field type, the response includes results that are formatted as `coordinates`. @@ -651,6 +656,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] The response includes only the IP address, ignoring all of the other data in the `message` field. @@ -701,6 +707,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] The script operates on the value provided for the `@timestamp` field to calculate and return the day of the week: @@ -762,6 +769,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] The response includes the calculated value from the script valuation: @@ -811,6 +819,7 @@ POST /_scripts/painless/_execute } } ``` +% TEST[continued] The response includes the values that the script emitted: diff --git a/docs/reference/scripting-languages/painless/painless-bucket-script-agg-context.md b/docs/reference/scripting-languages/painless/painless-bucket-script-agg-context.md index 1918d2a385b3f..54f79b2ef261c 100644 --- a/docs/reference/scripting-languages/painless/painless-bucket-script-agg-context.md +++ b/docs/reference/scripting-languages/painless/painless-bucket-script-agg-context.md @@ -80,6 +80,7 @@ GET /seats/_search } } ``` +% TEST[setup:seats] 1. The `buckets_path` points to two aggregations (`min_cost`, `max_cost`) and adds `min`/`max` variables to the `params` map 2. The user-specified `base_cost` is also added to the script’s `params` map diff --git a/docs/reference/scripting-languages/painless/painless-bucket-selector-agg-context.md b/docs/reference/scripting-languages/painless/painless-bucket-selector-agg-context.md index 99c047f5fb7dc..449366536f456 100644 --- a/docs/reference/scripting-languages/painless/painless-bucket-selector-agg-context.md +++ b/docs/reference/scripting-languages/painless/painless-bucket-selector-agg-context.md @@ -76,6 +76,7 @@ GET /seats/_search } } ``` +% TEST[setup:seats] 1. The `buckets_path` points to the max aggregations (`max_cost`) and adds `max` variables to the `params` map 2. The user-specified `base_cost` is also added to the `params` map diff --git a/docs/reference/scripting-languages/painless/painless-debugging.md b/docs/reference/scripting-languages/painless/painless-debugging.md index fc2a7230f144b..70e89cdf3e72a 100644 --- a/docs/reference/scripting-languages/painless/painless-debugging.md +++ b/docs/reference/scripting-languages/painless/painless-debugging.md @@ -24,6 +24,9 @@ POST /hockey/_explain/1 } } ``` +% TEST[s/_explain\/1/_explain\/1?error_trace=false/ catch:/painless_explain_error/] +% The test system sends error_trace=true by default for easier debugging so +% we have to override it to get a normal shaped response Which shows that the class of `doc.first` is `org.elasticsearch.index.fielddata.ScriptDocValues.Longs` by responding with: @@ -39,6 +42,7 @@ Which shows that the class of `doc.first` is `org.elasticsearch.index.fielddata. "status": 400 } ``` +% TESTRESPONSE[s/\.\.\./"script_stack": $body.error.script_stack, "script": $body.error.script, "lang": $body.error.lang, "position": $body.error.position, "caused_by": $body.error.caused_by, "root_cause": $body.error.root_cause, "reason": $body.error.reason/] You can use the same trick to see that `_source` is a `LinkedHashMap` in the `_update` API: @@ -48,6 +52,7 @@ POST /hockey/_update/1 "script": "Debug.explain(ctx._source)" } ``` +% TEST[continued s/_update\/1/_update\/1?error_trace=false/ catch:/painless_explain_error/] The response looks like: @@ -68,6 +73,9 @@ The response looks like: "status": 400 } ``` +% TESTRESPONSE[s/"root_cause": \.\.\./"root_cause": $body.error.root_cause/] +% TESTRESPONSE[s/\.\.\./"script_stack": $body.error.caused_by.script_stack, "script": $body.error.caused_by.script, "lang": $body.error.caused_by.lang, "position": $body.error.caused_by.position, "caused_by": $body.error.caused_by.caused_by, "reason": $body.error.caused_by.reason/] +% TESTRESPONSE[s/"to_string": ".+"/"to_string": $body.error.caused_by.to_string/] Once you have a class you can go to [*Painless API Reference*](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-api-reference.html) to see a list of available methods. diff --git a/docs/reference/scripting-languages/painless/painless-field-context.md b/docs/reference/scripting-languages/painless/painless-field-context.md index dda3c30f1a9e2..ac103db733433 100644 --- a/docs/reference/scripting-languages/painless/painless-field-context.md +++ b/docs/reference/scripting-languages/painless/painless-field-context.md @@ -73,6 +73,7 @@ GET seats/_search } } ``` +% TEST[setup:seats] ```console-result { @@ -121,4 +122,5 @@ GET seats/_search } } ``` +% TESTRESPONSE[s/"took" : 68/"took" : "$body.took"/] diff --git a/docs/reference/scripting-languages/painless/painless-filter-context.md b/docs/reference/scripting-languages/painless/painless-filter-context.md index 6f605b36b9363..4a8868afce090 100644 --- a/docs/reference/scripting-languages/painless/painless-filter-context.md +++ b/docs/reference/scripting-languages/painless/painless-filter-context.md @@ -57,4 +57,4 @@ GET seats/_search } } ``` - +% TEST[setup:seats] diff --git a/docs/reference/scripting-languages/painless/painless-min-should-match-context.md b/docs/reference/scripting-languages/painless/painless-min-should-match-context.md index fd9766d1d5cd0..05d29ba3b5b98 100644 --- a/docs/reference/scripting-languages/painless/painless-min-should-match-context.md +++ b/docs/reference/scripting-languages/painless/painless-min-should-match-context.md @@ -67,4 +67,5 @@ GET seats/_search } } ``` +% TEST[setup:seats] diff --git a/docs/reference/scripting-languages/painless/painless-runtime-fields-context.md b/docs/reference/scripting-languages/painless/painless-runtime-fields-context.md index bacb74cf209b4..1fbac613e0f79 100644 --- a/docs/reference/scripting-languages/painless/painless-runtime-fields-context.md +++ b/docs/reference/scripting-languages/painless/painless-runtime-fields-context.md @@ -111,6 +111,7 @@ PUT seats/_mapping } } ``` +% TEST[setup:seats] After defining the runtime field and script in the mappings, you can run a query that includes a terms aggregation for `day_of_week`. When the query runs, {{es}} evaluates the included Painless script and dynamically generates a value based on the script definition: @@ -132,6 +133,7 @@ GET seats/_search } } ``` +% TEST[continued] The response includes `day_of_week` for each hit. {{es}} calculates the value for this field dynamically at search time by operating on the `datetime` field defined in the mappings. @@ -172,4 +174,4 @@ The response includes `day_of_week` for each hit. {{es}} calculates the value fo } } ``` - +% TESTRESPONSE[s/\.\.\./"took" : $body.took,"timed_out" : $body.timed_out,"_shards" : $body._shards,/] diff --git a/docs/reference/scripting-languages/painless/painless-score-context.md b/docs/reference/scripting-languages/painless/painless-score-context.md index 34d4c43d26511..dbb64fb76581f 100644 --- a/docs/reference/scripting-languages/painless/painless-score-context.md +++ b/docs/reference/scripting-languages/painless/painless-score-context.md @@ -54,4 +54,5 @@ GET /seats/_search } } ``` +% TEST[setup:seats] diff --git a/docs/reference/scripting-languages/painless/painless-update-by-query-context.md b/docs/reference/scripting-languages/painless/painless-update-by-query-context.md index 582417987c22c..17e4ac429860d 100644 --- a/docs/reference/scripting-languages/painless/painless-update-by-query-context.md +++ b/docs/reference/scripting-languages/painless/painless-update-by-query-context.md @@ -85,4 +85,4 @@ POST /seats/_update_by_query } } ``` - +% TEST[setup:seats] diff --git a/docs/reference/scripting-languages/painless/painless-update-context.md b/docs/reference/scripting-languages/painless/painless-update-context.md index 3f3a949cb0750..b8d4cfbc2f77d 100644 --- a/docs/reference/scripting-languages/painless/painless-update-context.md +++ b/docs/reference/scripting-languages/painless/painless-update-context.md @@ -70,4 +70,4 @@ POST /seats/_update/3 } } ``` - +% TEST[setup:seats] diff --git a/docs/reference/scripting-languages/painless/use-painless-scripts-in-runtime-fields.md b/docs/reference/scripting-languages/painless/use-painless-scripts-in-runtime-fields.md index 176d28c911d28..6508bd10c56c5 100644 --- a/docs/reference/scripting-languages/painless/use-painless-scripts-in-runtime-fields.md +++ b/docs/reference/scripting-languages/painless/use-painless-scripts-in-runtime-fields.md @@ -45,7 +45,7 @@ PUT my-index/ } } ``` - +% TESTSETUP ## Define a runtime field only in a search request [painless-runtime-fields-query] diff --git a/docs/reference/scripting-languages/painless/using-datetime-in-painless.md b/docs/reference/scripting-languages/painless/using-datetime-in-painless.md index 4cb4e11ed5e67..85f1c8b094e8c 100644 --- a/docs/reference/scripting-languages/painless/using-datetime-in-painless.md +++ b/docs/reference/scripting-languages/painless/using-datetime-in-painless.md @@ -575,6 +575,7 @@ Under most Painless contexts the current datetime, `now`, is not supported. Ther } } ``` + % NOTCONSOLE * Input: @@ -588,6 +589,7 @@ Under most Painless contexts the current datetime, `now`, is not supported. Ther } ... ``` + % NOTCONSOLE * Script: @@ -597,6 +599,7 @@ Under most Painless contexts the current datetime, `now`, is not supported. Ther long millisDateTime = inputDateTime.toInstant().toEpochMilli(); long elapsedTime = now - millisDateTime; ``` + % NOTCONSOLE * Use a string datetime as `now` @@ -622,6 +625,7 @@ Under most Painless contexts the current datetime, `now`, is not supported. Ther } } ``` + % NOTCONSOLE * Input: @@ -635,6 +639,7 @@ Under most Painless contexts the current datetime, `now`, is not supported. Ther } ... ``` + % NOTCONSOLE * Script: @@ -646,6 +651,7 @@ Under most Painless contexts the current datetime, `now`, is not supported. Ther long millisDateTime = zdt.toInstant().toEpochMilli(); long elapsedTime = now - millisDateTime; ``` + % NOTCONSOLE 1. Note this parses the same string datetime every time the script runs. Use a numeric datetime to avoid a significant performance hit. @@ -678,6 +684,7 @@ Run the following curl commands to load the data necessary for the context examp } } ``` + % TESTSETUP 2. Load the sample data. @@ -704,6 +711,7 @@ Run the following curl commands to load the data necessary for the context examp { "index" : { "_index" : "messages", "_id" : "10" } } { "priority": 2, "datetime": "2019-07-23T23:39:54Z", "message": "m10" } ``` + % TEST[continued] @@ -741,7 +749,7 @@ GET /messages/_search?pretty=true } } ``` - +% TEST[continued] ### Age of a Message Script Field Example [_age_of_a_message_script_field_example] @@ -765,6 +773,7 @@ GET /_search?pretty=true } } ``` + TEST[continued] The following shows the script broken into multiple lines: diff --git a/docs/reference/search-connectors/api-tutorial.md b/docs/reference/search-connectors/api-tutorial.md index 2813a724be098..1f60520d6eac6 100644 --- a/docs/reference/search-connectors/api-tutorial.md +++ b/docs/reference/search-connectors/api-tutorial.md @@ -6,7 +6,6 @@ applies_to: elasticsearch: ga mapped_pages: - https://www.elastic.co/guide/en/elasticsearch/reference/current/es-connectors-tutorial-api.html -description: Use APIs to synchronize data from a PostgreSQL data source into Elasticsearch. --- # Connector API tutorial [es-connectors-tutorial-api] @@ -63,6 +62,7 @@ Let’s test that we can access {{es}}: ```sh curl -s -X GET -u elastic:$ELASTIC_PASSWORD http://localhost:9200 ``` +% NOTCONSOLE Note: With {{es}} running locally, you will need to pass the username and password to authenticate against {{es}} in the configuration file for the connector service. @@ -85,6 +85,7 @@ curl -s -X PUT http://localhost:9200/_connector/my-connector-id \ "service_type": "postgresql" }' ``` +% NOTCONSOLE Refer to [](/reference/search-connectors/es-postgresql-connector-client-tutorial.md) for instructions on creating an API key. @@ -116,6 +117,7 @@ Run the following command to download the file to the `~/data` directory: ```sh curl -L https://raw.githubusercontent.com/lerocha/chinook-database/master/ChinookDatabase/DataSources/Chinook_PostgreSql.sql -o ~/data/Chinook_PostgreSql.sql ``` +% NOTCONSOLE Now we need to import the example data into the PostgreSQL container and create the tables. @@ -155,6 +157,7 @@ PUT _connector/my-connector-id "service_type": "postgresql" } ``` +% TEST[skip:TODO] ::::{tip} `service_type` refers to the third-party data source you’re connecting to. @@ -210,6 +213,7 @@ POST /_security/api_key } } ``` +% TEST[skip:TODO] You’ll need to use the `encoded` value from the response as the `elasticsearch.api_key` in your configuration file. @@ -240,7 +244,8 @@ connectors: We provide an [example configuration file](https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example) in the `elastic/connectors` repository for reference. -### Run the service [es-connectors-tutorial-api-run-connector-service] + +#### Run the connector service [es-connectors-tutorial-api-run-connector-service] Now that we have the configuration file set up, we can run the connector service locally. This will point your connector instance at your {{es}} deployment. @@ -262,6 +267,8 @@ Verify your connector is connected by getting the connector status (should be `n ```console GET _connector/my-connector-id ``` +% TEST[skip:TODO] + ## Configure the connector [es-connectors-tutorial-api-update-connector-configuration] @@ -293,6 +300,7 @@ PUT _connector/my-connector-id/_configuration } } ``` +% TEST[skip:TODO] ::::{note} Configuration details are specific to the connector type. The keys and values will differ depending on which third-party data source you’re connecting to. Refer to the individual connectors-references,connector references for these configuration details. @@ -310,6 +318,7 @@ POST _connector/_sync_job "job_type": "full" } ``` +% TEST[skip:TODO] To store data in {{es}}, the connector needs to create an index. When we created the connector, we specified the `music` index. The connector will create and configure this {{es}} index before launching the sync job. @@ -325,6 +334,7 @@ Use the [get sync job API]({{es-apis}}operation/operation-connector-sync-job-get ```console GET _connector/_sync_job?connector_id=my-connector-id&size=1 ``` +% TEST[skip:TODO] The job document will be updated as the sync progresses, you can check it as often as you’d like to poll for updates. @@ -337,12 +347,15 @@ Verify that data is present in the `music` index with the following API call: ```console GET music/_count ``` +% TEST[skip:TODO] {{es}} stores data in documents, which are JSON objects. List the individual documents with the following API call: ```console GET music/_search ``` +% TEST[skip:TODO] + ## Troubleshoot [es-connectors-tutorial-api-troubleshooting] @@ -351,6 +364,7 @@ Use the following command to inspect the latest sync job’s status: ```console GET _connector/_sync_job?connector_id=my-connector-id&size=1 ``` +% TEST[skip:TODO] If the connector encountered any errors during the sync, you’ll find these in the `error` field. @@ -362,12 +376,14 @@ To delete the connector and its associated sync jobs run this command: ```console DELETE _connector/my-connector-id&delete_sync_jobs=true ``` +% TEST[skip:TODO] This won’t delete the Elasticsearch index that was created by the connector to store the data. Delete the `music` index by running the following command: ```console DELETE music ``` +% TEST[skip:TODO] To remove the PostgreSQL container, run the following commands: diff --git a/docs/reference/search-connectors/es-connectors-azure-blob.md b/docs/reference/search-connectors/es-connectors-azure-blob.md index eb39afce55117..96f461cfb9110 100644 --- a/docs/reference/search-connectors/es-connectors-azure-blob.md +++ b/docs/reference/search-connectors/es-connectors-azure-blob.md @@ -54,6 +54,7 @@ PUT _connector/my-azure_blob_storage-connector "service_type": "azure_blob_storage" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -146,6 +147,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-box.md b/docs/reference/search-connectors/es-connectors-box.md index 87005f73fefdd..f65396630f377 100644 --- a/docs/reference/search-connectors/es-connectors-box.md +++ b/docs/reference/search-connectors/es-connectors-box.md @@ -53,6 +53,7 @@ PUT _connector/my-box-connector "service_type": "box" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -194,6 +195,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-confluence.md b/docs/reference/search-connectors/es-connectors-confluence.md index 8ee6cce74e5d3..34a8b2d822809 100644 --- a/docs/reference/search-connectors/es-connectors-confluence.md +++ b/docs/reference/search-connectors/es-connectors-confluence.md @@ -55,6 +55,7 @@ PUT _connector/my-confluence-connector "service_type": "confluence" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -204,6 +205,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -308,6 +310,7 @@ This connector supports [advanced sync rules](/reference/search-connectors/es-sy } ] ``` +% NOTCONSOLE **Example 2**: Queries for indexing data based on `created` and `lastmodified` time. @@ -321,6 +324,7 @@ This connector supports [advanced sync rules](/reference/search-connectors/es-sy } ] ``` +% NOTCONSOLE **Example 3**: Query for indexing only given types in a **Space** with key *SD*. @@ -331,6 +335,7 @@ This connector supports [advanced sync rules](/reference/search-connectors/es-sy } ] ``` +% NOTCONSOLE ::::{note} Syncing recently created/updated items in Confluence may be delayed when using advanced sync rules, because the search endpoint used for CQL queries returns stale results in the response. For more details refer to the following issue in the [Confluence documentation](https://jira.atlassian.com/browse/CONFCLOUD-73997). diff --git a/docs/reference/search-connectors/es-connectors-dropbox.md b/docs/reference/search-connectors/es-connectors-dropbox.md index 997fdbbe4cb30..7af5b16080f9c 100644 --- a/docs/reference/search-connectors/es-connectors-dropbox.md +++ b/docs/reference/search-connectors/es-connectors-dropbox.md @@ -51,6 +51,7 @@ PUT _connector/my-dropbox-connector "service_type": "dropbox" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -214,6 +215,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -338,6 +340,7 @@ $$$es-connectors-dropbox-client-sync-rules-advanced-example-1$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-dropbox-client-sync-rules-advanced-example-2$$$ **Example: Query with file extension filter** @@ -355,6 +358,7 @@ $$$es-connectors-dropbox-client-sync-rules-advanced-example-2$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-dropbox-client-sync-rules-advanced-example-3$$$ **Example: Query with file category filter** @@ -376,6 +380,7 @@ $$$es-connectors-dropbox-client-sync-rules-advanced-example-3$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-dropbox-client-sync-rules-advanced-limitations$$$ **Limitations** diff --git a/docs/reference/search-connectors/es-connectors-github.md b/docs/reference/search-connectors/es-connectors-github.md index 9df0f97b4d007..060293e9a515e 100644 --- a/docs/reference/search-connectors/es-connectors-github.md +++ b/docs/reference/search-connectors/es-connectors-github.md @@ -52,6 +52,7 @@ PUT _connector/my-github-connector "service_type": "github" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -239,6 +240,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -361,6 +363,7 @@ $$$es-connectors-github-client-sync-rules-advanced-branch$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-github-client-sync-rules-advanced-issue-key$$$ **Indexing document based on issue query related to bugs via issue key** @@ -375,6 +378,7 @@ $$$es-connectors-github-client-sync-rules-advanced-issue-key$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-github-client-sync-rules-advanced-pr-key$$$ **Indexing document based on PR query related to open PR’s via PR key** @@ -389,6 +393,7 @@ $$$es-connectors-github-client-sync-rules-advanced-pr-key$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-github-client-sync-rules-advanced-issue-query-branch-name$$$ **Indexing document and files based on queries and branch name** @@ -405,6 +410,7 @@ $$$es-connectors-github-client-sync-rules-advanced-issue-query-branch-name$$$ } ] ``` +% NOTCONSOLE ::::{note} All documents pulled by a given rule are indexed regardless of whether the document has already been indexed by a previous rule. This can lead to document duplication, but the indexed documents count will differ in the logs. Check the Elasticsearch index for the actual document count. @@ -431,6 +437,7 @@ $$$es-connectors-github-client-sync-rules-advanced-overlapping$$$ } ] ``` +% NOTCONSOLE ::::{note} If `GitHub App` is selected as the authentication method, the "OWNER/" portion of the "OWNER/REPO" repository argument must be provided. diff --git a/docs/reference/search-connectors/es-connectors-gmail.md b/docs/reference/search-connectors/es-connectors-gmail.md index 14208204f138e..acddb679a1bc9 100644 --- a/docs/reference/search-connectors/es-connectors-gmail.md +++ b/docs/reference/search-connectors/es-connectors-gmail.md @@ -49,6 +49,7 @@ PUT _connector/my-gmail-connector "service_type": "gmail" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -176,6 +177,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -266,6 +268,7 @@ For example: ] } ``` +% NOTCONSOLE ### Document level security [es-connectors-gmail-client-document-level-security] diff --git a/docs/reference/search-connectors/es-connectors-google-cloud.md b/docs/reference/search-connectors/es-connectors-google-cloud.md index b6bca451e75ac..1d7b0fdc62ec6 100644 --- a/docs/reference/search-connectors/es-connectors-google-cloud.md +++ b/docs/reference/search-connectors/es-connectors-google-cloud.md @@ -60,6 +60,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-google-drive.md b/docs/reference/search-connectors/es-connectors-google-drive.md index 1336c11e99c56..28afece6ac4ba 100644 --- a/docs/reference/search-connectors/es-connectors-google-drive.md +++ b/docs/reference/search-connectors/es-connectors-google-drive.md @@ -127,6 +127,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-graphql.md b/docs/reference/search-connectors/es-connectors-graphql.md index 00bd8347c110e..7c9059820baa6 100644 --- a/docs/reference/search-connectors/es-connectors-graphql.md +++ b/docs/reference/search-connectors/es-connectors-graphql.md @@ -45,6 +45,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -145,6 +146,7 @@ Note the following configuration fields: } } ``` + % NOTCONSOLE `graphql_variables` @@ -170,6 +172,7 @@ Note the following configuration fields: "organization.users": "user_id" } ``` + % NOTCONSOLE In this example `user_id` is unique in every user document. Therefore, we set `user_id` as the value for `organization.users`. @@ -187,6 +190,7 @@ Note the following configuration fields: "content-type": "Application/json" } ``` + % NOTCONSOLE `pagination_model` (required) @@ -213,6 +217,7 @@ Note the following configuration fields: } } ``` + % NOTCONSOLE The value of `pagination_key` is `sampleData.users` so it must contain: diff --git a/docs/reference/search-connectors/es-connectors-jira.md b/docs/reference/search-connectors/es-connectors-jira.md index d83636a193864..c607c7ddbe147 100644 --- a/docs/reference/search-connectors/es-connectors-jira.md +++ b/docs/reference/search-connectors/es-connectors-jira.md @@ -55,6 +55,7 @@ PUT _connector/my-jira-connector "service_type": "jira" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -204,6 +205,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -319,6 +321,7 @@ This connector supports [advanced sync rules](/reference/search-connectors/es-sy } ] ``` +% NOTCONSOLE **Example 2**: Query to index data based on priority of issues for given projects. @@ -329,6 +332,7 @@ This connector supports [advanced sync rules](/reference/search-connectors/es-sy } ] ``` +% NOTCONSOLE **Example 3**: Query to index data based on assignee and created time. @@ -339,6 +343,7 @@ This connector supports [advanced sync rules](/reference/search-connectors/es-sy } ] ``` +% NOTCONSOLE ### Document level security [es-connectors-jira-client-document-level-security] diff --git a/docs/reference/search-connectors/es-connectors-mongodb.md b/docs/reference/search-connectors/es-connectors-mongodb.md index a194fea9eb579..f1ee0ba99028f 100644 --- a/docs/reference/search-connectors/es-connectors-mongodb.md +++ b/docs/reference/search-connectors/es-connectors-mongodb.md @@ -114,6 +114,7 @@ PUT _connector/my-mongodb-connector "service_type": "mongodb" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -196,6 +197,7 @@ Incorrect (`new Date()` will be interpreted as string): } } ``` +% NOTCONSOLE Correct (usage of [$$NOW](https://www.mongodb.com/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.NOW)): @@ -224,6 +226,7 @@ Correct (usage of [$$NOW](https://www.mongodb.com/docs/manual/reference/aggregat } } ``` +% NOTCONSOLE #### Connecting with self-signed or custom CA TLS Cert [es-connectors-mongodb-client-known-issues-tls-with-invalid-cert] @@ -287,6 +290,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -411,6 +415,7 @@ For `find` queries, the structure of this JSON DSL should look like: } } ``` +% NOTCONSOLE For example: @@ -428,6 +433,7 @@ For example: } } ``` +% NOTCONSOLE `find` queries also support additional options, for example the `projection` object: @@ -448,6 +454,7 @@ For example: } } ``` +% NOTCONSOLE Where the available options are: @@ -480,6 +487,7 @@ Similarly, for aggregation pipelines, the structure of the JSON DSL should look } } ``` +% NOTCONSOLE Where the available options are: diff --git a/docs/reference/search-connectors/es-connectors-ms-sql.md b/docs/reference/search-connectors/es-connectors-ms-sql.md index c033101ff7d23..b64cab89040f4 100644 --- a/docs/reference/search-connectors/es-connectors-ms-sql.md +++ b/docs/reference/search-connectors/es-connectors-ms-sql.md @@ -47,6 +47,7 @@ PUT _connector/my-mssql-connector "service_type": "mssql" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -200,6 +201,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -333,6 +335,7 @@ These rules fetch all records from both the `employee` and `customer` tables. Th } ] ``` +% NOTCONSOLE $$$es-connectors-ms-sql-client-sync-rules-example-one-where$$$ **Example: One WHERE query** @@ -347,6 +350,7 @@ This rule fetches only the records from the `employee` table where the `emp_id` } ] ``` +% NOTCONSOLE $$$es-connectors-ms-sql-client-sync-rules-example-one-join$$$ **Example: One JOIN query** @@ -361,6 +365,7 @@ This rule fetches records by performing an INNER JOIN between the `employee` and } ] ``` +% NOTCONSOLE ::::{warning} When using advanced rules, a query can bypass the configuration field `tables`. This will happen if the query specifies a table that doesn’t appear in the configuration. This can also happen if the configuration specifies `*` to fetch all tables while the advanced sync rule requests for only a subset of tables. diff --git a/docs/reference/search-connectors/es-connectors-mysql.md b/docs/reference/search-connectors/es-connectors-mysql.md index 45138d35b9886..d96f2394c6570 100644 --- a/docs/reference/search-connectors/es-connectors-mysql.md +++ b/docs/reference/search-connectors/es-connectors-mysql.md @@ -48,6 +48,7 @@ PUT _connector/my-mysql-connector "service_type": "mysql" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -274,6 +275,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -360,6 +362,7 @@ For example: } ] ``` +% NOTCONSOLE ::::{warning} When using advanced rules, a query can bypass the configuration field `tables`. This will happen if the query specifies a table that doesn’t appear in the configuration. This can also happen if the configuration specifies `*` to fetch all tables while the advanced sync rule requests for only a subset of tables. diff --git a/docs/reference/search-connectors/es-connectors-network-drive.md b/docs/reference/search-connectors/es-connectors-network-drive.md index 72ee00251ef49..fbce94742bb76 100644 --- a/docs/reference/search-connectors/es-connectors-network-drive.md +++ b/docs/reference/search-connectors/es-connectors-network-drive.md @@ -107,6 +107,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -246,6 +247,7 @@ $$$es-connectors-network-drive-client-indexing-files-and-folders-recursively-wit } ] ``` +% NOTCONSOLE $$$es-connectors-network-drive-client-indexing-files-and-folders-directly-inside-folder$$$ **Indexing files and folders directly inside folder** @@ -257,6 +259,7 @@ $$$es-connectors-network-drive-client-indexing-files-and-folders-directly-inside } ] ``` +% NOTCONSOLE $$$es-connectors-network-drive-client-indexing-files-and-folders-directly-inside-a-set-of-folders$$$ **Indexing files and folders directly inside a set of folders** @@ -268,6 +271,7 @@ $$$es-connectors-network-drive-client-indexing-files-and-folders-directly-inside } ] ``` +% NOTCONSOLE $$$es-connectors-network-drive-client-excluding-files-and-folders-that-match-a-pattern$$$ **Excluding files and folders that match a pattern** @@ -279,6 +283,7 @@ $$$es-connectors-network-drive-client-excluding-files-and-folders-that-match-a-p } ] ``` +% NOTCONSOLE ### Content extraction [es-connectors-network-drive-client-content-extraction] diff --git a/docs/reference/search-connectors/es-connectors-notion.md b/docs/reference/search-connectors/es-connectors-notion.md index 2b6adb57e0bd8..1637ec04b69e7 100644 --- a/docs/reference/search-connectors/es-connectors-notion.md +++ b/docs/reference/search-connectors/es-connectors-notion.md @@ -63,6 +63,7 @@ PUT _connector/my-notion-connector "service_type": "notion" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -129,6 +130,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -303,6 +305,7 @@ Indexing every page where the title contains `Demo Page`: ] } ``` +% NOTCONSOLE **Example 2** @@ -320,6 +323,7 @@ Indexing every database where the title contains `Demo Database`: ] } ``` +% NOTCONSOLE **Example 3** @@ -343,6 +347,7 @@ Indexing every database where the title contains `Demo Database` and every page ] } ``` +% NOTCONSOLE **Example 4** @@ -360,6 +365,7 @@ Indexing all pages in the workspace: ] } ``` +% NOTCONSOLE **Example 5** @@ -374,6 +380,7 @@ Indexing all the pages and databases connected to the workspace: ] } ``` +% NOTCONSOLE **Example 6** @@ -394,6 +401,7 @@ Indexing all the rows of a database where the record is `true` for the column `T ] } ``` +% NOTCONSOLE **Example 7** @@ -408,6 +416,7 @@ Indexing all rows of a specific database: ] } ``` +% NOTCONSOLE **Example 8** @@ -442,6 +451,7 @@ Indexing all blocks defined in `searches` and `database_query_filters`: ] } ``` +% NOTCONSOLE ::::{note} In this example the `filter` object syntax for `database_query_filters` is defined per the [Notion documentation](https://developers.notion.com/reference/post-database-query-filter). diff --git a/docs/reference/search-connectors/es-connectors-onedrive.md b/docs/reference/search-connectors/es-connectors-onedrive.md index fa13dfa24d848..26cfb43a2267d 100644 --- a/docs/reference/search-connectors/es-connectors-onedrive.md +++ b/docs/reference/search-connectors/es-connectors-onedrive.md @@ -51,6 +51,7 @@ PUT _connector/my-onedrive-connector "service_type": "onedrive" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -136,6 +137,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -311,6 +313,7 @@ This rule skips indexing for files with `.xlsx` and `.docx` extensions. All othe } ] ``` +% NOTCONSOLE $$$es-connectors-onedrive-client-sync-rules-advanced-examples-2$$$ **Example 2** @@ -325,6 +328,7 @@ This rule focuses on indexing files and folders owned by `user1-domain@onmicroso } ] ``` +% NOTCONSOLE $$$es-connectors-onedrive-client-sync-rules-advanced-examples-3$$$ **Example 3** @@ -339,6 +343,7 @@ This rule indexes only the files and folders directly inside the root folder, ex } ] ``` +% NOTCONSOLE $$$es-connectors-onedrive-client-sync-rules-advanced-examples-4$$$ **Example 4** @@ -354,6 +359,7 @@ This rule indexes files and folders owned by `user1-domain@onmicrosoft.com` and } ] ``` +% NOTCONSOLE $$$es-connectors-onedrive-client-sync-rules-advanced-examples-5$$$ **Example 5** @@ -370,6 +376,7 @@ This example contains two rules. The first rule indexes all files and folders ow } ] ``` +% NOTCONSOLE $$$es-connectors-onedrive-client-sync-rules-advanced-examples-6$$$ **Example 6** @@ -387,6 +394,7 @@ This example contains two rules. The first rule indexes all files owned by `user } ] ``` +% NOTCONSOLE ### Content Extraction [es-connectors-onedrive-client-content-extraction] diff --git a/docs/reference/search-connectors/es-connectors-oracle.md b/docs/reference/search-connectors/es-connectors-oracle.md index 2f98a78df31c5..41d80477c22c9 100644 --- a/docs/reference/search-connectors/es-connectors-oracle.md +++ b/docs/reference/search-connectors/es-connectors-oracle.md @@ -38,6 +38,7 @@ PUT _connector/my-oracle-connector "service_type": "oracle" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -195,6 +196,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-outlook.md b/docs/reference/search-connectors/es-connectors-outlook.md index fcc4033b60bc4..02375e4959d1c 100644 --- a/docs/reference/search-connectors/es-connectors-outlook.md +++ b/docs/reference/search-connectors/es-connectors-outlook.md @@ -41,6 +41,7 @@ PUT _connector/my-outlook-connector "service_type": "outlook" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -194,6 +195,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-postgresql.md b/docs/reference/search-connectors/es-connectors-postgresql.md index 05a4ac397efaf..446731629d14f 100644 --- a/docs/reference/search-connectors/es-connectors-postgresql.md +++ b/docs/reference/search-connectors/es-connectors-postgresql.md @@ -47,6 +47,7 @@ PUT _connector/my-postgresql-connector "service_type": "postgresql" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -213,6 +214,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -347,6 +349,7 @@ $$$es-connectors-postgresql-client-sync-rules-advanced-examples-1$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-postgresql-client-sync-rules-advanced-examples-1-id-columns$$$ **Multiple table queries with `id_columns`** @@ -371,6 +374,7 @@ In 8.15.0, we added a new optional `id_columns` field in our advanced sync rules } ] ``` +% NOTCONSOLE This example uses the `id_columns` field to specify the unique fields `emp_id` and `c_id` for the `employee` and `customer` tables, respectively. @@ -385,6 +389,7 @@ $$$es-connectors-postgresql-client-sync-rules-advanced-examples-2$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-postgresql-client-sync-rules-advanced-examples-3$$$ **`JOIN` operations** @@ -397,6 +402,7 @@ $$$es-connectors-postgresql-client-sync-rules-advanced-examples-3$$$ } ] ``` +% NOTCONSOLE ::::{warning} When using advanced rules, a query can bypass the configuration field `tables`. This will happen if the query specifies a table that doesn’t appear in the configuration. This can also happen if the configuration specifies `*` to fetch all tables while the advanced sync rule requests for only a subset of tables. diff --git a/docs/reference/search-connectors/es-connectors-redis.md b/docs/reference/search-connectors/es-connectors-redis.md index 19445637a1aa6..9fef8b349b7d4 100644 --- a/docs/reference/search-connectors/es-connectors-redis.md +++ b/docs/reference/search-connectors/es-connectors-redis.md @@ -43,6 +43,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -219,6 +220,7 @@ Provide at least one of the following: `key_pattern` or `type`, or both. } ] ``` +% NOTCONSOLE #### Example 2 [es-connectors-redis-connector-advanced-sync-rules-example-2] @@ -233,6 +235,7 @@ Provide at least one of the following: `key_pattern` or `type`, or both. } ] ``` +% NOTCONSOLE #### Example 3 [es-connectors-redis-connector-advanced-sync-rules-example-3] @@ -246,6 +249,7 @@ Provide at least one of the following: `key_pattern` or `type`, or both. "key_pattern": "test[123]" } ``` +% NOTCONSOLE #### Example 4 [es-connectors-redis-connector-advanced-sync-rules-example-4] @@ -260,6 +264,7 @@ Provide at least one of the following: `key_pattern` or `type`, or both. } ] ``` +% NOTCONSOLE #### Example 5 [es-connectors-redis-connector-advanced-sync-rules-example-5] @@ -274,6 +279,7 @@ Provide at least one of the following: `key_pattern` or `type`, or both. } ] ``` +% NOTCONSOLE #### Example 6 [es-connectors-redis-connector-advanced-sync-rules-example-6] @@ -289,6 +295,7 @@ Provide at least one of the following: `key_pattern` or `type`, or both. } ] ``` +% NOTCONSOLE #### Example 7 [es-connectors-redis-connector-advanced-sync-rules-example-7] @@ -303,6 +310,7 @@ Provide at least one of the following: `key_pattern` or `type`, or both. } ] ``` +% NOTCONSOLE ## Connector Client operations [es-connectors-redis-connector-connector-client-operations] diff --git a/docs/reference/search-connectors/es-connectors-run-from-docker.md b/docs/reference/search-connectors/es-connectors-run-from-docker.md index 0d39f753e02d7..9714a5b76d7ee 100644 --- a/docs/reference/search-connectors/es-connectors-run-from-docker.md +++ b/docs/reference/search-connectors/es-connectors-run-from-docker.md @@ -22,6 +22,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output /connectors-config/config.yml ``` +% NOTCONSOLE Don’t forget to change the `--output` argument value to the path where you want to save the `config.yml` file on your local system. But keep note of where you wrote this file, as it is required in the `docker run` step below. diff --git a/docs/reference/search-connectors/es-connectors-s3.md b/docs/reference/search-connectors/es-connectors-s3.md index cb3ed900901fa..d264735184e74 100644 --- a/docs/reference/search-connectors/es-connectors-s3.md +++ b/docs/reference/search-connectors/es-connectors-s3.md @@ -44,6 +44,7 @@ PUT _connector/my-s3-connector "service_type": "s3" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -168,6 +169,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -277,6 +279,7 @@ $$$es-connectors-s3-client-sync-rules-advanced-examples$$$ ] ``` +% NOTCONSOLE **Example**: Fetch files/folder starting with `folder1`. @@ -288,6 +291,7 @@ $$$es-connectors-s3-client-sync-rules-advanced-examples$$$ } ] ``` +% NOTCONSOLE **Fetching files and folders by specifying extensions** @@ -302,6 +306,7 @@ $$$es-connectors-s3-client-sync-rules-advanced-examples$$$ } ] ``` +% NOTCONSOLE ### Content extraction [es-connectors-s3-client-content-extraction] diff --git a/docs/reference/search-connectors/es-connectors-salesforce.md b/docs/reference/search-connectors/es-connectors-salesforce.md index c8170571f8242..73cedd4dda936 100644 --- a/docs/reference/search-connectors/es-connectors-salesforce.md +++ b/docs/reference/search-connectors/es-connectors-salesforce.md @@ -53,6 +53,7 @@ PUT _connector/my-salesforce-connector "service_type": "salesforce" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -192,6 +193,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -363,6 +365,7 @@ $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-query-language$$$ } ] ``` +% NOTCONSOLE **Example**: Fetch documents using SOSL query. @@ -374,6 +377,7 @@ $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-query-language$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-objects$$$ **Fetch standard and custom objects using SOQL and SOSL queries** @@ -392,6 +396,7 @@ $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-objects$$$ } ] ``` +% NOTCONSOLE **Example**: Fetch documents for custom objects via SOQL and SOSL query. @@ -407,6 +412,7 @@ $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-objects$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-standard-custom-fields$$$ **Fetch documents with standard and custom fields** @@ -421,6 +427,7 @@ $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-standard-custom-fie } ] ``` +% NOTCONSOLE **Example**: Fetch documents with all custom fields for Connector object. @@ -432,6 +439,7 @@ $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-standard-custom-fie } ] ``` +% NOTCONSOLE **Example**: Fetch documents with all standard fields for Account object. @@ -443,6 +451,7 @@ $$$es-connectors-salesforce-client-sync-rules-advanced-fetch-standard-custom-fie } ] ``` +% NOTCONSOLE ### Documents and syncs [es-connectors-salesforce-client-documents-syncs] diff --git a/docs/reference/search-connectors/es-connectors-sandfly.md b/docs/reference/search-connectors/es-connectors-sandfly.md index 99ec3a51ad997..b6a39a96893c8 100644 --- a/docs/reference/search-connectors/es-connectors-sandfly.md +++ b/docs/reference/search-connectors/es-connectors-sandfly.md @@ -174,6 +174,7 @@ You can either download it manually or run the following command: ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -222,7 +223,7 @@ docker.elastic.co/integrations/elastic-connectors:{{version.stack}} \ /app/bin/elastic-ingest \ -c /config/config.yml ``` - +% NOTCONSOLE :::: @@ -298,7 +299,6 @@ For faster tests, add the `DATA_SIZE=small` flag: make ftest NAME=sandfly DATA_SIZE=small ``` - ### Known issues [es-connectors-sandfly-client-known-issues] There are currently no known issues for this connector. diff --git a/docs/reference/search-connectors/es-connectors-servicenow.md b/docs/reference/search-connectors/es-connectors-servicenow.md index 81ec9a5226223..bbb123c3a11d4 100644 --- a/docs/reference/search-connectors/es-connectors-servicenow.md +++ b/docs/reference/search-connectors/es-connectors-servicenow.md @@ -49,6 +49,7 @@ PUT _connector/my-servicenow-connector "service_type": "servicenow" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -222,6 +223,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -312,6 +314,7 @@ $$$es-connectors-servicenow-client-sync-rules-number-incident-service$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-servicenow-client-sync-rules-active-false-user-service$$$ **Indexing document based on user activity state for User service** @@ -324,6 +327,7 @@ $$$es-connectors-servicenow-client-sync-rules-active-false-user-service$$$ } ] ``` +% NOTCONSOLE $$$es-connectors-servicenow-client-sync-rules-author-administrator-knowledge-service$$$ **Indexing document based on author name for Knowledge service** @@ -336,6 +340,7 @@ $$$es-connectors-servicenow-client-sync-rules-author-administrator-knowledge-ser } ] ``` +% NOTCONSOLE ### End-to-end Testing [es-connectors-servicenow-client-connector-client-operations-testing] diff --git a/docs/reference/search-connectors/es-connectors-sharepoint-online.md b/docs/reference/search-connectors/es-connectors-sharepoint-online.md index 674c4ea567d0b..9eaca596ce0fe 100644 --- a/docs/reference/search-connectors/es-connectors-sharepoint-online.md +++ b/docs/reference/search-connectors/es-connectors-sharepoint-online.md @@ -283,6 +283,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. @@ -401,6 +402,7 @@ Example: "skipExtractingDriveItemsOlderThan": 60 } ``` +% NOTCONSOLE This rule will not extract content of any drive items (files in document libraries) that haven’t been modified for 60 days or more. @@ -514,6 +516,7 @@ POST INDEX_NAME/_update_by_query?conflicts=proceed } } ``` +% TEST[skip:TODO] ### Document-level security [es-connectors-sharepoint-online-client-dls] diff --git a/docs/reference/search-connectors/es-connectors-sharepoint.md b/docs/reference/search-connectors/es-connectors-sharepoint.md index c76e547b5a0c1..c6e141029f22f 100644 --- a/docs/reference/search-connectors/es-connectors-sharepoint.md +++ b/docs/reference/search-connectors/es-connectors-sharepoint.md @@ -57,6 +57,7 @@ PUT _connector/my-sharepoint_server-connector "service_type": "sharepoint_server" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -194,6 +195,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-slack.md b/docs/reference/search-connectors/es-connectors-slack.md index ecf06ce1bc596..5bc16b08bc675 100644 --- a/docs/reference/search-connectors/es-connectors-slack.md +++ b/docs/reference/search-connectors/es-connectors-slack.md @@ -56,6 +56,7 @@ PUT _connector/my-slack-connector "service_type": "slack" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -155,6 +156,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-teams.md b/docs/reference/search-connectors/es-connectors-teams.md index 1c2df8517c713..56676bea1679f 100644 --- a/docs/reference/search-connectors/es-connectors-teams.md +++ b/docs/reference/search-connectors/es-connectors-teams.md @@ -53,6 +53,7 @@ PUT _connector/my-microsoft_teams-connector "service_type": "microsoft_teams" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -185,6 +186,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-connectors-zoom.md b/docs/reference/search-connectors/es-connectors-zoom.md index 6fe806167f380..7a0177dbb9ad3 100644 --- a/docs/reference/search-connectors/es-connectors-zoom.md +++ b/docs/reference/search-connectors/es-connectors-zoom.md @@ -53,6 +53,7 @@ PUT _connector/my-zoom-connector "service_type": "zoom" } ``` +% TEST[skip:can’t test in isolation] :::::{dropdown} You’ll also need to create an API key for the connector to use. ::::{note} @@ -184,6 +185,7 @@ Download the sample configuration file. You can either download it manually or r ```sh curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml ``` +% NOTCONSOLE Remember to update the `--output` argument value if your directory name is different, or you want to use a different config file name. diff --git a/docs/reference/search-connectors/es-dls-e2e-guide.md b/docs/reference/search-connectors/es-dls-e2e-guide.md index fc56fcb5e7c34..77c2f5b558e4b 100644 --- a/docs/reference/search-connectors/es-dls-e2e-guide.md +++ b/docs/reference/search-connectors/es-dls-e2e-guide.md @@ -116,6 +116,7 @@ The access control index will contain documents similar to this example: } } ``` +% NOTCONSOLE This document contains the Elasticsearch query that describes which documents the user `john@example.com` has access to. The access control information is stored in the `access_control` field. In this case the user has access only to documents that contain `"john@example.co"` or `"Engineering Members"` in the `_allow_access_control` field. @@ -181,6 +182,7 @@ POST /_security/api_key } } ``` +% TEST[skip:TODO] The response will look like this: @@ -193,6 +195,7 @@ The response will look like this: "encoded": "Qk05dy1JZ0JhRDNyNGpLQ3MwUmk6elRzdGU5QjZUY21SSWdkMldnQ1RMZw==" } ``` +% NOTCONSOLE The `api_key` field contains the API key that can be used to query the Search Application with the appropriate DLS restrictions. @@ -225,6 +228,7 @@ GET .search-acl-filter-source1 } } ``` +% NOTCONSOLE ```js GET .search-acl-filter-source2 @@ -246,6 +250,7 @@ GET .search-acl-filter-source2 } } ``` +% NOTCONSOLE `.search-acl-filter-source1` and `.search-acl-filter-source2` define the access control identities for `source1` and `source2`. @@ -352,6 +357,7 @@ createApiKey({ }, }).then((encodedKey) => console.log(encodedKey)); ``` +% NOTCONSOLE ::::{note} The example combines multiple identities into a single role descriptor. This is because an Elasticsearch API key can use role restrictions only if it has a **single role descriptor**. diff --git a/docs/reference/search-connectors/es-dls-overview.md b/docs/reference/search-connectors/es-dls-overview.md index 4315b1d54b277..f799349820ec1 100644 --- a/docs/reference/search-connectors/es-dls-overview.md +++ b/docs/reference/search-connectors/es-dls-overview.md @@ -76,6 +76,7 @@ These documents define the access control policy for the data indexed into Elast } } ``` +% NOTCONSOLE In this example, the identity object specifies the identity of the user that this document pertains to. The `query` object then uses a template to list the parameters that form the access control policy for this identity. It also contains the query `source`, which will specify a query to fetch all content documents the identity has access to. The `_id` could be, for example, the email address or the username of a user. The exact content and structure of `identity` depends on the corresponding implementation. @@ -97,6 +98,7 @@ Content documents contain the actual data from your 3rd party source. A specific ] } ``` +% NOTCONSOLE ### Access control sync vs content sync [es-dls-overview-sync-type-comparison] @@ -145,6 +147,7 @@ One access control document: } } ``` +% NOTCONSOLE Let’s see which of the following example documents these permissions can access, and why. @@ -158,6 +161,7 @@ Let’s see which of the following example documents these permissions can acces ] } ``` +% NOTCONSOLE The user `example username` will have access to this document as he’s part of the corresponding group and his username and email address are also explicitly part of `_allow_access_control`. @@ -169,6 +173,7 @@ The user `example username` will have access to this document as he’s part of ] } ``` +% NOTCONSOLE The user `example username` will also have access to this document as they are part of the `example group`. @@ -180,6 +185,7 @@ The user `example username` will also have access to this document as they are p ] } ``` +% NOTCONSOLE The user `example username` won’t have access to this document because their email does not match `another.user@example.com`. @@ -189,6 +195,7 @@ The user `example username` won’t have access to this document because their e "_allow_access_control": [] } ``` +% NOTCONSOLE No one will have access to this document as the `_allow_access_control` field is empty. @@ -224,6 +231,7 @@ GET .search-acl-filter-source1 } } ``` +% NOTCONSOLE ```js GET .search-acl-filter-source2 @@ -245,6 +253,7 @@ GET .search-acl-filter-source2 } } ``` +% NOTCONSOLE `.search-acl-filter-source1` and `.search-acl-filter-source2` define the access control identities for `source1` and `source2`. @@ -294,6 +303,7 @@ POST /_security/api_key } } ``` +% TEST[skip:TODO] #### Workflow guidance [es-dls-overview-multiple-connectors-workflow-guidance] diff --git a/docs/reference/search-connectors/es-sync-rules.md b/docs/reference/search-connectors/es-sync-rules.md index ed7f24c6aa027..59a1dc021fb49 100644 --- a/docs/reference/search-connectors/es-sync-rules.md +++ b/docs/reference/search-connectors/es-sync-rules.md @@ -234,6 +234,7 @@ A sample apartment looks like this in the `.json` format: } } ``` +% NOTCONSOLE The target data set should fulfill the following conditions: @@ -303,6 +304,7 @@ Let’s assume that the apartment data is stored inside a MongoDB instance. For } ] ``` +% NOTCONSOLE 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`: diff --git a/docs/reference/text-analysis/analysis-delimited-payload-tokenfilter.md b/docs/reference/text-analysis/analysis-delimited-payload-tokenfilter.md index f705206e046a6..942d2a511d1fa 100644 --- a/docs/reference/text-analysis/analysis-delimited-payload-tokenfilter.md +++ b/docs/reference/text-analysis/analysis-delimited-payload-tokenfilter.md @@ -166,6 +166,7 @@ POST text_payloads/_doc/1 "text": "the|0 brown|3 fox|4 is|0 quick|10" } ``` +% TEST[continued] Use the [term vectors API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-termvectors) to return the document’s tokens and base64-encoded payloads. @@ -176,6 +177,7 @@ GET text_payloads/_termvectors/1 "payloads": true } ``` +% TEST[continued] The API returns the following response: @@ -244,5 +246,6 @@ The API returns the following response: } } ``` +% TESTRESPONSE[s/"took": 8/"took": "$body.took"/] diff --git a/docs/reference/text-analysis/analysis-hyp-decomp-tokenfilter.md b/docs/reference/text-analysis/analysis-hyp-decomp-tokenfilter.md index 70e7213b99e38..eb58497d8a76c 100644 --- a/docs/reference/text-analysis/analysis-hyp-decomp-tokenfilter.md +++ b/docs/reference/text-analysis/analysis-hyp-decomp-tokenfilter.md @@ -29,6 +29,7 @@ GET _analyze "text": "Kaffeetasse" } ``` +% TEST[skip: requires a valid hyphenation_patterns.xml file for DE-DR] The filter produces the following tokens: diff --git a/docs/reference/text-analysis/analysis-keyword-analyzer.md b/docs/reference/text-analysis/analysis-keyword-analyzer.md index a0fc3cd00f777..d28c609fd0715 100644 --- a/docs/reference/text-analysis/analysis-keyword-analyzer.md +++ b/docs/reference/text-analysis/analysis-keyword-analyzer.md @@ -58,6 +58,7 @@ PUT /keyword_example } } ``` +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: keyword_example, first: keyword, second: rebuilt_keyword}\nendyaml\n/] 1. You’d add any token filters here. diff --git a/docs/reference/text-analysis/analysis-keyword-repeat-tokenfilter.md b/docs/reference/text-analysis/analysis-keyword-repeat-tokenfilter.md index 531cb3c1a66f7..10dc98e1fa4e5 100644 --- a/docs/reference/text-analysis/analysis-keyword-repeat-tokenfilter.md +++ b/docs/reference/text-analysis/analysis-keyword-repeat-tokenfilter.md @@ -130,6 +130,7 @@ The API returns the following response. Note that one version of each token has } } ``` +% TESTRESPONSE[s/"tokenizer": .../"tokenizer": $body.detail.tokenizer/] :::: @@ -240,6 +241,8 @@ The API returns the following response. Note the following changes: } } ``` +% TESTRESPONSE[s/"tokenizer": .../"tokenizer": $body.detail.tokenizer/] +% TESTRESPONSE[s/"tokens": .../"tokens": $body.$_path/] :::: @@ -338,6 +341,8 @@ The API returns the following response. Note that the duplicate tokens for `fox` } } ``` +% TESTRESPONSE[s/"tokenizer": .../"tokenizer": $body.detail.tokenizer/] +% TESTRESPONSE[s/"tokens": ...​/"tokens": $body.$_path/] :::: diff --git a/docs/reference/text-analysis/analysis-lang-analyzer.md b/docs/reference/text-analysis/analysis-lang-analyzer.md index 9b8ec02d9cb5f..4d928d5d876b6 100644 --- a/docs/reference/text-analysis/analysis-lang-analyzer.md +++ b/docs/reference/text-analysis/analysis-lang-analyzer.md @@ -73,6 +73,8 @@ PUT /arabic_example } } ``` +% TEST[s/"arabic_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: arabic_example, first: arabic, second: rebuilt_arabic}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -117,6 +119,8 @@ PUT /armenian_example } } ``` +% TEST[s/"armenian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: armenian_example, first: armenian, second: rebuilt_armenian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -161,6 +165,8 @@ PUT /basque_example } } ``` +% TEST[s/"basque_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: basque_example, first: basque, second: rebuilt_basque}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -208,6 +214,8 @@ PUT /bengali_example } } ``` +% TEST[s/"bengali_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: bengali_example, first: bengali, second: rebuilt_bengali}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -252,6 +260,8 @@ PUT /brazilian_example } } ``` +% TEST[s/"brazilian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: brazilian_example, first: brazilian, second: rebuilt_brazilian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -296,6 +306,8 @@ PUT /bulgarian_example } } ``` +% TEST[s/"bulgarian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: bulgarian_example, first: bulgarian, second: rebuilt_bulgarian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -346,6 +358,8 @@ PUT /catalan_example } } ``` +% TEST[s/"catalan_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: catalan_example, first: catalan, second: rebuilt_catalan}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -393,6 +407,8 @@ PUT /cjk_example } } ``` +% TEST[s/"cjk_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: cjk_example, first: cjk, second: rebuilt_cjk}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. The default stop words are **almost** the same as the `_english_` set, but not exactly the same. @@ -436,6 +452,8 @@ PUT /czech_example } } ``` +% TEST[s/"czech_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: czech_example, first: czech, second: rebuilt_czech}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -480,6 +498,8 @@ PUT /danish_example } } ``` +% TEST[s/"danish_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: danish_example, first: danish, second: rebuilt_danish}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -534,6 +554,8 @@ PUT /dutch_example } } ``` +% TEST[s/"dutch_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: dutch_example, first: dutch, second: rebuilt_dutch}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -583,6 +605,8 @@ PUT /english_example } } ``` +% TEST[s/"english_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: english_example, first: english, second: rebuilt_english}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -627,6 +651,8 @@ PUT /estonian_example } } ``` +% TEST[s/"estonian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: estonian_example, first: estonian, second: rebuilt_estonian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -671,6 +697,8 @@ PUT /finnish_example } } ``` +% TEST[s/"finnish_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: finnish_example, first: finnish, second: rebuilt_finnish}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -725,6 +753,8 @@ PUT /french_example } } ``` +% TEST[s/"french_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: french_example, first: french, second: rebuilt_french}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -769,6 +799,8 @@ PUT /galician_example } } ``` +% TEST[s/"galician_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: galician_example, first: galician, second: rebuilt_galician}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -814,6 +846,8 @@ PUT /german_example } } ``` +% TEST[s/"german_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: german_example, first: german, second: rebuilt_german}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -862,6 +896,8 @@ PUT /greek_example } } ``` +% TEST[s/"greek_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: greek_example, first: greek, second: rebuilt_greek}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -909,6 +945,8 @@ PUT /hindi_example } } ``` +% TEST[s/"hindi_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: hindi_example, first: hindi, second: rebuilt_hindi}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -953,6 +991,8 @@ PUT /hungarian_example } } ``` +% TEST[s/"hungarian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: hungarian_example, first: hungarian, second: rebuilt_hungarian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -997,6 +1037,8 @@ PUT /indonesian_example } } ``` +% TEST[s/"indonesian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: indonesian_example, first: indonesian, second: rebuilt_indonesian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1057,6 +1099,8 @@ PUT /irish_example } } ``` +% TEST[s/"irish_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: irish_example, first: irish, second: rebuilt_irish}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1112,6 +1156,8 @@ PUT /italian_example } } ``` +% TEST[s/"italian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: italian_example, first: italian, second: rebuilt_italian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1156,6 +1202,8 @@ PUT /latvian_example } } ``` +% TEST[s/"latvian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: latvian_example, first: latvian, second: rebuilt_latvian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1200,6 +1248,8 @@ PUT /lithuanian_example } } ``` +% TEST[s/"lithuanian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: lithuanian_example, first: lithuanian, second: rebuilt_lithuanian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1244,6 +1294,8 @@ PUT /norwegian_example } } ``` +% TEST[s/"norwegian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: norwegian_example, first: norwegian, second: rebuilt_norwegian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1289,6 +1341,7 @@ PUT /persian_example } } ``` +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: persian_example, first: persian, second: rebuilt_persian}\nendyaml\n/] 1. Replaces zero-width non-joiners with an ASCII space. 2. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. @@ -1333,6 +1386,8 @@ PUT /portuguese_example } } ``` +% TEST[s/"portuguese_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: portuguese_example, first: portuguese, second: rebuilt_portuguese}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1377,6 +1432,8 @@ PUT /romanian_example } } ``` +% TEST[s/"romanian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: romanian_example, first: romanian, second: rebuilt_romanian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1421,6 +1478,8 @@ PUT /russian_example } } ``` +% TEST[s/"russian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: russian_example, first: russian, second: rebuilt_russian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1466,6 +1525,8 @@ PUT /serbian_example } } ``` +% TEST[s/"serbian_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: serbian_example, first: serbian, second: rebuilt_serbian}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1512,6 +1573,8 @@ PUT /sorani_example } } ``` +% TEST[s/"sorani_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: sorani_example, first: sorani, second: rebuilt_sorani}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1556,6 +1619,8 @@ PUT /spanish_example } } ``` +% TEST[s/"spanish_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: spanish_example, first: spanish, second: rebuilt_spanish}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1600,6 +1665,8 @@ PUT /swedish_example } } ``` +% TEST[s/"swedish_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: swedish_example, first: swedish, second: rebuilt_swedish}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1649,6 +1716,8 @@ PUT /turkish_example } } ``` +% TEST[s/"turkish_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: turkish_example, first: turkish, second: rebuilt_turkish}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. This filter should be removed unless there are words which should be excluded from stemming. @@ -1684,6 +1753,8 @@ PUT /thai_example } } ``` +% TEST[s/"thai_keywords",//] +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: thai_example, first: thai, second: rebuilt_thai}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. diff --git a/docs/reference/text-analysis/analysis-mapping-charfilter.md b/docs/reference/text-analysis/analysis-mapping-charfilter.md index d418ff09ae649..a0d07f67328b6 100644 --- a/docs/reference/text-analysis/analysis-mapping-charfilter.md +++ b/docs/reference/text-analysis/analysis-mapping-charfilter.md @@ -111,6 +111,7 @@ GET /my-index-000001/_analyze "text": "I'm delighted about it :(" } ``` +% TEST[continued] The filter produces the following text: diff --git a/docs/reference/text-analysis/analysis-multiplexer-tokenfilter.md b/docs/reference/text-analysis/analysis-multiplexer-tokenfilter.md index 83f083f2e3e98..b634a2604e0c3 100644 --- a/docs/reference/text-analysis/analysis-multiplexer-tokenfilter.md +++ b/docs/reference/text-analysis/analysis-multiplexer-tokenfilter.md @@ -64,6 +64,7 @@ POST /multiplexer_example/_analyze "text" : "Going HOME" } ``` +% TEST[continued] And it’d respond: diff --git a/docs/reference/text-analysis/analysis-pathhierarchy-tokenizer.md b/docs/reference/text-analysis/analysis-pathhierarchy-tokenizer.md index 139d7ea7a613e..bff4ea77f175d 100644 --- a/docs/reference/text-analysis/analysis-pathhierarchy-tokenizer.md +++ b/docs/reference/text-analysis/analysis-pathhierarchy-tokenizer.md @@ -182,6 +182,7 @@ GET file-path-test/_search } } ``` +% TEST[continued] It’s simple to match or filter documents with file paths that exist within a particular directory using the `file_path.tree` field. @@ -195,6 +196,7 @@ GET file-path-test/_search } } ``` +% TEST[continued] With the reverse parameter for this tokenizer, it’s also possible to match from the other end of the file path, such as individual file names or a deep level subdirectory. The following example shows a search for all files named `my_photo1.jpg` within any directory via the `file_path.tree_reversed` field configured to use the reverse parameter in the mapping. @@ -210,6 +212,7 @@ GET file-path-test/_search } } ``` +% TEST[continued] Viewing the tokens generated with both forward and reverse is instructive in showing the tokens created for the same file path value. @@ -226,6 +229,7 @@ POST file-path-test/_analyze "text": "/User/alice/photos/2017/05/16/my_photo1.jpg" } ``` +% TEST[continued] It’s also useful to be able to filter with file paths when combined with other types of searches, such as this example looking for any files paths with `16` that also must be in Alice’s photo directory. @@ -244,4 +248,5 @@ GET file-path-test/_search } } ``` +% TEST[continued] diff --git a/docs/reference/text-analysis/analysis-pattern-analyzer.md b/docs/reference/text-analysis/analysis-pattern-analyzer.md index 9fc6dd696939d..5d2690e55dbd8 100644 --- a/docs/reference/text-analysis/analysis-pattern-analyzer.md +++ b/docs/reference/text-analysis/analysis-pattern-analyzer.md @@ -183,6 +183,7 @@ PUT /pattern_example } } ``` +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: pattern_example, first: pattern, second: rebuilt_pattern}\nendyaml\n/] 1. The default pattern is `\W+` which splits on non-word characters and this is where you’d change it. 2. You’d add other token filters after `lowercase`. diff --git a/docs/reference/text-analysis/analysis-pattern-replace-charfilter.md b/docs/reference/text-analysis/analysis-pattern-replace-charfilter.md index 3fbdd968e3d71..9d1b7d4a79747 100644 --- a/docs/reference/text-analysis/analysis-pattern-replace-charfilter.md +++ b/docs/reference/text-analysis/analysis-pattern-replace-charfilter.md @@ -70,6 +70,7 @@ POST my-index-000001/_analyze "text": "My credit card is 123-456-789" } ``` +% TEST[s/\$1//] The above example produces the following terms: @@ -154,6 +155,7 @@ GET my-index-000001/_search } } ``` +% TEST[continued] The output from the above is: @@ -191,6 +193,7 @@ The output from the above is: } } ``` +% TESTRESPONSE[s/"took".*/"took": "$body.took",/] 1. Note the incorrect highlight. diff --git a/docs/reference/text-analysis/analysis-standard-analyzer.md b/docs/reference/text-analysis/analysis-standard-analyzer.md index 2d14d16172600..7074e0509bb56 100644 --- a/docs/reference/text-analysis/analysis-standard-analyzer.md +++ b/docs/reference/text-analysis/analysis-standard-analyzer.md @@ -109,6 +109,7 @@ PUT /standard_example } } ``` +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: standard_example, first: standard, second: rebuilt_standard}\nendyaml\n/] 1. You’d add any token filters after `lowercase`. diff --git a/docs/reference/text-analysis/analysis-stop-analyzer.md b/docs/reference/text-analysis/analysis-stop-analyzer.md index 7349fe386a786..494cd0e4bc09f 100644 --- a/docs/reference/text-analysis/analysis-stop-analyzer.md +++ b/docs/reference/text-analysis/analysis-stop-analyzer.md @@ -110,6 +110,7 @@ PUT /stop_example } } ``` +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: stop_example, first: stop, second: rebuilt_stop}\nendyaml\n/] 1. The default stopwords can be overridden with the `stopwords` or `stopwords_path` parameters. 2. You’d add any token filters after `english_stop`. diff --git a/docs/reference/text-analysis/analysis-whitespace-analyzer.md b/docs/reference/text-analysis/analysis-whitespace-analyzer.md index c4f67dd2cd36e..e9cb105cf20e2 100644 --- a/docs/reference/text-analysis/analysis-whitespace-analyzer.md +++ b/docs/reference/text-analysis/analysis-whitespace-analyzer.md @@ -20,6 +20,85 @@ POST _analyze } ``` + + The above sentence would produce the following terms: ```text @@ -58,6 +137,7 @@ PUT /whitespace_example } } ``` +% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: whitespace_example, first: whitespace, second: rebuilt_whitespace}\nendyaml\n/] 1. You’d add any token filters here.