-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into set-processor
- Loading branch information
Showing
9 changed files
with
467 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
--- | ||
layout: default | ||
title: Median absolute deviation | ||
parent: Metric aggregations | ||
grand_parent: Aggregations | ||
nav_order: 65 | ||
redirect_from: | ||
- /query-dsl/aggregations/metric/median-absolute-deviation/ | ||
--- | ||
|
||
# Median absolute deviation aggregations | ||
|
||
The `median_absolute_deviation` metric is a single-value metric aggregation that returns a median absolute deviation field. Median absolute deviation is a statistical measure of data variability. Because the median absolute deviation measures dispersion from the median, it provides a more robust measure of variability that is less affected by outliers in a dataset. | ||
|
||
Median absolute deviation is calculated as follows:<br> | ||
median_absolute_deviation = median(|X<sub>i</sub> - Median(X<sub>i</sub>)|) | ||
|
||
The following example calculates the median absolute deviation of the `DistanceMiles` field in the sample dataset `opensearch_dashboards_sample_data_flights`: | ||
|
||
|
||
```json | ||
GET opensearch_dashboards_sample_data_flights/_search | ||
{ | ||
"size": 0, | ||
"aggs": { | ||
"median_absolute_deviation_DistanceMiles": { | ||
"median_absolute_deviation": { | ||
"field": "DistanceMiles" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
#### Example response | ||
|
||
```json | ||
{ | ||
"took": 35, | ||
"timed_out": false, | ||
"_shards": { | ||
"total": 1, | ||
"successful": 1, | ||
"skipped": 0, | ||
"failed": 0 | ||
}, | ||
"hits": { | ||
"total": { | ||
"value": 10000, | ||
"relation": "gte" | ||
}, | ||
"max_score": null, | ||
"hits": [] | ||
}, | ||
"aggregations": { | ||
"median_absolute_deviation_distanceMiles": { | ||
"value": 1829.8993624441966 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Missing | ||
|
||
By default, if a field is missing or has a null value in a document, it is ignored during computation. However, you can specify a value to be used for those missing or null fields by using the `missing` parameter, as shown in the following request: | ||
|
||
```json | ||
GET opensearch_dashboards_sample_data_flights/_search | ||
{ | ||
"size": 0, | ||
"aggs": { | ||
"median_absolute_deviation_distanceMiles": { | ||
"median_absolute_deviation": { | ||
"field": "DistanceMiles", | ||
"missing": 1000 | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
#### Example response | ||
|
||
```json | ||
{ | ||
"took": 7, | ||
"timed_out": false, | ||
"_shards": { | ||
"total": 1, | ||
"successful": 1, | ||
"skipped": 0, | ||
"failed": 0 | ||
}, | ||
"hits": { | ||
"total": { | ||
"value": 10000, | ||
"relation": "gte" | ||
}, | ||
"max_score": null, | ||
"hits": [] | ||
}, | ||
"aggregations": { | ||
"median_absolute_deviation_distanceMiles": { | ||
"value": 1829.6443646143355 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Compression | ||
|
||
The median absolute deviation is calculated using the [t-digest](https://github.com/tdunning/t-digest/tree/main) data structure, which balances between performance and estimation accuracy through the `compression` parameter (default value: `1000`). Adjusting the `compression` value affects the trade-off between computational efficiency and precision. Lower `compression` values improve performance but may reduce estimation accuracy, while higher values enhance accuracy at the cost of increased computational overhead, as shown in the following request: | ||
|
||
```json | ||
GET opensearch_dashboards_sample_data_flights/_search | ||
{ | ||
"size": 0, | ||
"aggs": { | ||
"median_absolute_deviation_DistanceMiles": { | ||
"median_absolute_deviation": { | ||
"field": "DistanceMiles", | ||
"compression": 10 | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
#### Example response | ||
|
||
```json | ||
{ | ||
"took": 1, | ||
"timed_out": false, | ||
"_shards": { | ||
"total": 1, | ||
"successful": 1, | ||
"skipped": 0, | ||
"failed": 0 | ||
}, | ||
"hits": { | ||
"total": { | ||
"value": 10000, | ||
"relation": "gte" | ||
}, | ||
"max_score": null, | ||
"hits": [] | ||
}, | ||
"aggregations": { | ||
"median_absolute_deviation_DistanceMiles": { | ||
"value": 1836.265614211182 | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
--- | ||
layout: default | ||
title: Join | ||
parent: Ingest processors | ||
nav_order: 160 | ||
--- | ||
|
||
# Join processor | ||
|
||
The `join` processor concatenates the elements of an array into a single string value, using a specified separator between each element. It throws an exception if the provided input is not an array. | ||
|
||
The following is the syntax for the `join` processor: | ||
|
||
```json | ||
{ | ||
"join": { | ||
"field": "field_name", | ||
"separator": "separator_string" | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Configuration parameters | ||
|
||
The following table lists the required and optional parameters for the `join` processor. | ||
|
||
Parameter | Required/Optional | Description | | ||
|-----------|-----------|-----------| | ||
`field` | Required | The name of the field to which the join operator is applied. Must be an array. | ||
`separator` | Required | A string separator to use when joining field values. If not specified, then the values are concatenated without a separator. | ||
`target_field` | Optional | The field to assign the cleaned value to. If not specified, then the field is updated in place. | ||
`description` | Optional | A description of the processor's purpose or configuration. | ||
`if` | Optional | Specifies to conditionally execute the processor. | ||
`ignore_failure` | Optional | Specifies to ignore failures for the processor. See [Handling pipeline failures]({{site.url}}{{site.baseurl}}/ingest-pipelines/pipeline-failures/). | ||
`on_failure` | Optional | Specifies to handle failures for the processor. See [Handling pipeline failures]({{site.url}}{{site.baseurl}}/ingest-pipelines/pipeline-failures/). | ||
`tag` | Optional | An identifier for the processor. Useful for debugging and metrics. | ||
|
||
## Using the processor | ||
|
||
Follow these steps to use the processor in a pipeline. | ||
|
||
### Step 1: Create a pipeline | ||
|
||
The following query creates a pipeline named `example-join-pipeline` that uses the `join` processor to concatenate all the values of the `uri` field, separating them with the specified separator `/`: | ||
|
||
```json | ||
PUT _ingest/pipeline/example-join-pipeline | ||
{ | ||
"description": "Example pipeline using the join processor", | ||
"processors": [ | ||
{ | ||
"join": { | ||
"field": "uri", | ||
"separator": "/" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
### Step 2 (Optional): Test the pipeline | ||
|
||
It is recommended that you test your pipeline before you ingest documents. | ||
{: .tip} | ||
|
||
To test the pipeline, run the following query: | ||
|
||
```json | ||
POST _ingest/pipeline/example-join-pipeline/_simulate | ||
{ | ||
"docs": [ | ||
{ | ||
"_source": { | ||
"uri": [ | ||
"app", | ||
"home", | ||
"overview" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
#### Response | ||
|
||
The following example response confirms that the pipeline is working as expected: | ||
|
||
```json | ||
{ | ||
"docs": [ | ||
{ | ||
"doc": { | ||
"_index": "_index", | ||
"_id": "_id", | ||
"_source": { | ||
"uri": "app/home/overview" | ||
}, | ||
"_ingest": { | ||
"timestamp": "2024-05-24T02:16:01.00659117Z" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
### Step 3: Ingest a document | ||
|
||
The following query ingests a document into an index named `testindex1`: | ||
|
||
```json | ||
POST testindex1/_doc/1?pipeline=example-join-pipeline | ||
{ | ||
"uri": [ | ||
"app", | ||
"home", | ||
"overview" | ||
] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
### Step 4 (Optional): Retrieve the document | ||
|
||
To retrieve the document, run the following query: | ||
|
||
```json | ||
GET testindex1/_doc/1 | ||
``` | ||
{% include copy-curl.html %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.