Fixes site
This commit is contained in:
parent
2729ce3ccb
commit
73baf3f6db
31
_config.yml
31
_config.yml
|
@ -27,13 +27,19 @@ color_scheme: opensearch
|
|||
# Define Jekyll collections
|
||||
collections:
|
||||
# Define a collection named "tests", its documents reside in the "_tests" directory
|
||||
opensearch_docs:
|
||||
opensearch:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
opensearch_dashboards_docs:
|
||||
dashboards:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
opensearch_plugins_docs:
|
||||
plugins:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
clients:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
troubleshoot:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
external_links:
|
||||
|
@ -43,20 +49,23 @@ collections:
|
|||
just_the_docs:
|
||||
# Define the collections used in the theme
|
||||
collections:
|
||||
opensearch_docs:
|
||||
opensearch:
|
||||
name: OpenSearch
|
||||
# nav_exclude: true
|
||||
# nav_fold: true
|
||||
nav_fold: true
|
||||
# search_exclude: true
|
||||
opensearch_dashboards_docs:
|
||||
dashboards:
|
||||
name: OpenSearch Dashboards
|
||||
#nav_fold: true
|
||||
opensearch_plugins_docs:
|
||||
nav_fold: true
|
||||
plugins:
|
||||
name: Plugins
|
||||
#nav_fold: true
|
||||
opensearch_troubleshooting_docs:
|
||||
nav_fold: true
|
||||
clients:
|
||||
name: Clients
|
||||
nav_fold: true
|
||||
troubleshoot:
|
||||
name: Troubleshooting
|
||||
#nav_fold: true
|
||||
nav_fold: true
|
||||
external_links:
|
||||
name: External links
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
layout: default
|
||||
title: Gantt charts
|
||||
nav_order: 10
|
||||
has_toc: false
|
||||
---
|
||||
|
||||
# Gantt charts
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
layout: default
|
||||
title: OpenSearch Dashboards
|
||||
nav_order: 11
|
||||
has_children: true
|
||||
title: About Dashboards
|
||||
nav_order: 1
|
||||
has_children: false
|
||||
has_toc: false
|
||||
---
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
layout: default
|
||||
title: Install OpenSearch Dashboards
|
||||
nav_order: 2
|
||||
nav_order: 1
|
||||
has_children: true
|
||||
---
|
||||
|
|
@ -3,6 +3,7 @@ layout: default
|
|||
title: Notebooks (experimental)
|
||||
nav_order: 50
|
||||
redirect_from: /docs/notebooks/
|
||||
has_children: false
|
||||
---
|
||||
|
||||
# OpenSearch Dashboards notebooks (experimental)
|
|
@ -2,7 +2,6 @@
|
|||
layout: default
|
||||
title: Bucket Aggregations
|
||||
parent: Aggregations
|
||||
grand_parent: OpenSearch
|
||||
nav_order: 2
|
||||
has_children: false
|
||||
---
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
layout: default
|
||||
title: OpenSearch
|
||||
nav_order: 10
|
||||
has_children: true
|
||||
title: About OpenSearch
|
||||
nav_order: 1
|
||||
has_children: false
|
||||
has_toc: false
|
||||
---
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
layout: default
|
||||
title: Metric Aggregations
|
||||
parent: Aggregations
|
||||
grand_parent: OpenSearch
|
||||
nav_order: 1
|
||||
has_children: false
|
||||
---
|
|
@ -2,7 +2,6 @@
|
|||
layout: default
|
||||
title: Pipeline Aggregations
|
||||
parent: Aggregations
|
||||
grand_parent: OpenSearch
|
||||
nav_order: 4
|
||||
has_children: false
|
||||
---
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
layout: default
|
||||
title: Tasks API
|
||||
nav_order: 25
|
||||
nav_order: 25
|
||||
---
|
||||
|
||||
# Tasks API operation
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
layout: default
|
||||
title: Introduction to Dashboards
|
||||
nav_order: 1
|
||||
---
|
||||
|
||||
# About OpenSearch Dashboards
|
||||
|
||||
OpenSearch Dashboards is the default visualization tool for data in OpenSearch. It also serves as a user interface for many of the OpenSearch plugins, including security, alerting, Index State Management, SQL, and more.
|
||||
|
||||
|
||||
## Get started with OpenSearch Dashboards
|
||||
|
||||
1. After starting OpenSearch Dashboards, you can access it at port 5601. For example, http://localhost:5601.
|
||||
1. Log in with the default username `admin` and password `admin`.
|
||||
1. Choose **Try our sample data** and add the sample flight data.
|
||||
1. Choose **Discover** and search for a few flights.
|
||||
1. Choose **Dashboard**, **[Flights] Global Flight Dashboard**, and wait for the dashboard to load.
|
File diff suppressed because it is too large
Load Diff
|
@ -1,89 +0,0 @@
|
|||
---
|
||||
layout: default
|
||||
title: Introduction to OpenSearch
|
||||
nav_order: 1
|
||||
---
|
||||
|
||||
# Introduction to OpenSearch
|
||||
|
||||
OpenSearch is a distributed search and analytics engine based on [Apache Lucene](https://lucene.apache.org/). After adding your data to OpenSearch, you can perform full-text searches on it with all of the features you might expect: search by field, search multiple indices, boost fields, rank results by score, sort results by field, and aggregate results.
|
||||
|
||||
Unsurprisingly, people often use OpenSearch as the backend for a search application---think [Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:FAQ/Technical#What_software_is_used_to_run_Wikipedia?) or an online store. It offers excellent performance and can scale up and down as the needs of the application grow or shrink.
|
||||
|
||||
An equally popular, but less obvious use case is log analytics, in which you take the logs from an application, feed them into OpenSearch, and use the rich search and visualization functionality to identify issues. For example, a malfunctioning web server might throw a 500 error 0.5% of the time, which can be hard to notice unless you have a real-time graph of all HTTP status codes that the server has thrown in the past four hours. You can use [OpenSearch Dashboards](../opensearch-dashboards/) to build these sorts of visualizations from data in OpenSearch.
|
||||
|
||||
|
||||
## Clusters and nodes
|
||||
|
||||
Its distributed design means that you interact with OpenSearch *clusters*. Each cluster is a collection of one or more *nodes*, servers that store your data and process search requests.
|
||||
|
||||
You can run OpenSearch locally on a laptop---its system requirements are minimal---but you can also scale a single cluster to hundreds of powerful machines in a data center.
|
||||
|
||||
In a single node cluster, such as a laptop, one machine has to do everything: manage the state of the cluster, index and search data, and perform any preprocessing of data prior to indexing it. As a cluster grows, however, you can subdivide responsibilities. Nodes with fast disks and plenty of RAM might be great at indexing and searching data, whereas a node with plenty of CPU power and a tiny disk could manage cluster state. For more information on setting node types, see [Cluster formation](cluster/).
|
||||
|
||||
|
||||
## Indices and documents
|
||||
|
||||
OpenSearch organizes data into *indices*. Each index is a collection of JSON *documents*. If you have a set of raw encyclopedia articles or log lines that you want to add to OpenSearch, you must first convert them to [JSON](https://www.json.org/). A simple JSON document for a movie might look like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "The Wind Rises",
|
||||
"release_date": "2013-07-20"
|
||||
}
|
||||
```
|
||||
|
||||
When you add the document to an index, OpenSearch adds some metadata, such as the unique document *ID*:
|
||||
|
||||
```json
|
||||
{
|
||||
"_index": "<index-name>",
|
||||
"_type": "_doc",
|
||||
"_id": "<document-id>",
|
||||
"_version": 1,
|
||||
"_source": {
|
||||
"title": "The Wind Rises",
|
||||
"release_date": "2013-07-20"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Indices also contain mappings and settings:
|
||||
|
||||
- A *mapping* is the collection of *fields* that documents in the index have. In this case, those fields are `title` and `release_date`.
|
||||
- Settings include data like the index name, creation date, and number of shards.
|
||||
|
||||
## Primary and replica shards
|
||||
|
||||
OpenSearch splits indices into *shards* for even distribution across nodes in a cluster. For example, a 400 GB index might be too large for any single node in your cluster to handle, but split into ten shards, each one 40 GB, OpenSearch can distribute the shards across ten nodes and work with each shard individually.
|
||||
|
||||
By default, OpenSearch creates a *replica* shard for each *primary* shard. If you split your index into ten shards, for example, OpenSearch also creates ten replica shards. These replica shards act as backups in the event of a node failure---OpenSearch distributes replica shards to different nodes than their corresponding primary shards---but they also improve the speed and rate at which the cluster can process search requests. You might specify more than one replica per index for a search-heavy workload.
|
||||
|
||||
Despite being a piece of an OpenSearch index, each shard is actually a full Lucene index---confusing, we know. This detail is important, though, because each instance of Lucene is a running process that consumes CPU and memory. More shards is not necessarily better. Splitting a 400 GB index into 1,000 shards, for example, would place needless strain on your cluster. A good rule of thumb is to keep shard size between 10--50 GB.
|
||||
|
||||
|
||||
## REST API
|
||||
|
||||
You interact with OpenSearch clusters using the REST API, which offers a lot of flexibility. You can use clients like [curl](https://curl.haxx.se/) or any programming language that can send HTTP requests. To add a JSON document to an OpenSearch index (i.e. index a document), you send an HTTP request:
|
||||
|
||||
```json
|
||||
PUT https://<host>:<port>/<index-name>/_doc/<document-id>
|
||||
{
|
||||
"title": "The Wind Rises",
|
||||
"release_date": "2013-07-20"
|
||||
}
|
||||
```
|
||||
|
||||
To run a search for the document:
|
||||
|
||||
```
|
||||
GET https://<host>:<port>/<index-name>/_search?q=wind
|
||||
```
|
||||
|
||||
To delete the document:
|
||||
|
||||
```
|
||||
DELETE https://<host>:<port>/<index-name>/_doc/<document-id>
|
||||
```
|
||||
|
||||
You can change most OpenSearch settings using the REST API, modify indices, check the health of the cluster, get statistics---almost everything.
|
|
@ -1,635 +0,0 @@
|
|||
---
|
||||
layout: default
|
||||
title: Metric aggregations
|
||||
parent: Aggregations
|
||||
nav_order: 1
|
||||
---
|
||||
|
||||
# Metric Aggregations
|
||||
|
||||
Metric aggregations let you perform simple calculations such as finding the minimum, maximum, and average values of a field.
|
||||
|
||||
## Types of metric aggregations
|
||||
|
||||
Metric aggregations are of two types: single-value metric aggregations and multi-value metric aggregations.
|
||||
|
||||
### Single-value metric aggregations
|
||||
|
||||
Single-value metric aggregations return a single metric. For example, `sum`, `min`, `max`, `avg`, `cardinality`, and `value_count`.
|
||||
|
||||
### Multi-value metric aggregations
|
||||
|
||||
Multi-value metric aggregations return more than one metric. For example, `stats`, `extended_stats`, `matrix_stats`, `percentile`, `percentile_ranks`, `geo_bound`, `top_hits`, and `scripted_metric`.
|
||||
|
||||
## sum, min, max, avg
|
||||
|
||||
The `sum`, `min`, `max`, and `avg` metrics are single-value metric aggregations that return the sum, minimum, maximum, and average values of a field, respectively.
|
||||
|
||||
The following example calculates the total sum of the `taxful_total_price` field:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"sum_taxful_total_price": {
|
||||
"sum": {
|
||||
"field": "taxful_total_price"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample Response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"sum_taxful_total_price" : {
|
||||
"value" : 350884.12890625
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In a similar fashion, you can find the minimum, maximum, and average values of a field.
|
||||
|
||||
## cardinality
|
||||
|
||||
The `cardinality` metric is a single-value metric aggregation that counts the number of unique or distinct values of a field.
|
||||
|
||||
The following example finds the number of unique products in an eCommerce store:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"unique_products": {
|
||||
"cardinality": {
|
||||
"field": "products.product_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"unique_products" : {
|
||||
"value" : 7033
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The cardinality count is approximate.
|
||||
If you had tens of thousands of products in your store, an accurate cardinality calculation requires loading all the values into a hash set and returning its size. This approach doesn't scale well because it requires more memory and causes high latency.
|
||||
|
||||
You can control the trade-off between memory and accuracy with the `precision_threshold` setting. This setting defines the threshold below which counts are expected to be close to accurate. Above this value, counts might become a bit less accurate. The default value of `precision_threshold` is 3,000. The maximum supported value is 40,000.
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"unique_products": {
|
||||
"cardinality": {
|
||||
"field": "products.product_id",
|
||||
"precision_threshold": 10000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## value_count
|
||||
|
||||
The `value_count` metric is a single-value metric aggregation that calculates the number of values that an aggregation is based on.
|
||||
|
||||
For example, you can use the `value_count` metric with the `avg` metric to find how many numbers the aggregation uses to calculate an average value.
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"number_of_values": {
|
||||
"value_count": {
|
||||
"field": "taxful_total_price"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"number_of_values" : {
|
||||
"value" : 4675
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## stats, extended_stats, matrix_stats
|
||||
|
||||
The `stats` metric is a multi-value metric aggregation that returns all basic metrics such as `min`, `max`, `sum`, `avg`, and `value_count` in one aggregation query.
|
||||
|
||||
The following example returns the basic stats for the `taxful_total_price` field:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"stats_taxful_total_price": {
|
||||
"stats": {
|
||||
"field": "taxful_total_price"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"stats_taxful_total_price" : {
|
||||
"count" : 4675,
|
||||
"min" : 6.98828125,
|
||||
"max" : 2250.0,
|
||||
"avg" : 75.05542864304813,
|
||||
"sum" : 350884.12890625
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `extended_stats` aggregation is an extended version of the `stats` aggregation. Apart from including basic stats, `extended_stats` also returns stats such as `sum_of_squares`, `variance`, and `std_deviation`.
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"extended_stats_taxful_total_price": {
|
||||
"extended_stats": {
|
||||
"field": "taxful_total_price"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample Response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"extended_stats_taxful_total_price" : {
|
||||
"count" : 4675,
|
||||
"min" : 6.98828125,
|
||||
"max" : 2250.0,
|
||||
"avg" : 75.05542864304813,
|
||||
"sum" : 350884.12890625,
|
||||
"sum_of_squares" : 3.9367749294174194E7,
|
||||
"variance" : 2787.59157113862,
|
||||
"variance_population" : 2787.59157113862,
|
||||
"variance_sampling" : 2788.187974983536,
|
||||
"std_deviation" : 52.79764740155209,
|
||||
"std_deviation_population" : 52.79764740155209,
|
||||
"std_deviation_sampling" : 52.80329511482722,
|
||||
"std_deviation_bounds" : {
|
||||
"upper" : 180.6507234461523,
|
||||
"lower" : -30.53986616005605,
|
||||
"upper_population" : 180.6507234461523,
|
||||
"lower_population" : -30.53986616005605,
|
||||
"upper_sampling" : 180.66201887270256,
|
||||
"lower_sampling" : -30.551161586606312
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `std_deviation_bounds` object provides a visual variance of the data with an interval of plus/minus two standard deviations from the mean.
|
||||
To set the standard deviation to a different value, say 3, set `sigma` to 3:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"extended_stats_taxful_total_price": {
|
||||
"extended_stats": {
|
||||
"field": "taxful_total_price",
|
||||
"sigma": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `matrix_stats` aggregation generates advanced stats for multiple fields in a matrix form.
|
||||
The following example returns advanced stats in a matrix form for the `taxful_total_price` and `products.base_price` fields:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"matrix_stats_taxful_total_price": {
|
||||
"matrix_stats": {
|
||||
"fields": ["taxful_total_price", "products.base_price"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"matrix_stats_taxful_total_price" : {
|
||||
"doc_count" : 4675,
|
||||
"fields" : [
|
||||
{
|
||||
"name" : "products.base_price",
|
||||
"count" : 4675,
|
||||
"mean" : 34.994239430147196,
|
||||
"variance" : 360.5035285833703,
|
||||
"skewness" : 5.530161335032702,
|
||||
"kurtosis" : 131.16306324042148,
|
||||
"covariance" : {
|
||||
"products.base_price" : 360.5035285833703,
|
||||
"taxful_total_price" : 846.6489362233166
|
||||
},
|
||||
"correlation" : {
|
||||
"products.base_price" : 1.0,
|
||||
"taxful_total_price" : 0.8444765264325268
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "taxful_total_price",
|
||||
"count" : 4675,
|
||||
"mean" : 75.05542864304839,
|
||||
"variance" : 2788.1879749835402,
|
||||
"skewness" : 15.812149139924037,
|
||||
"kurtosis" : 619.1235507385902,
|
||||
"covariance" : {
|
||||
"products.base_price" : 846.6489362233166,
|
||||
"taxful_total_price" : 2788.1879749835402
|
||||
},
|
||||
"correlation" : {
|
||||
"products.base_price" : 0.8444765264325268,
|
||||
"taxful_total_price" : 1.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Statistic | Description
|
||||
:--- | :---
|
||||
`count` | The number of samples measured.
|
||||
`mean` | The average value of the field measured from the sample.
|
||||
`variance` | How far the values of the field measured are spread out from its mean value. The larger the variance, the more it's spread from its mean value.
|
||||
`skewness` | An asymmetric measure of the distribution of the field's values around the mean.
|
||||
`kurtosis` | A measure of the tail heaviness of a distribution. As the tail becomes lighter, kurtosis decreases. As the tail becomes heavier, kurtosis increases. To learn about kurtosis, see [Wikipedia](https://en.wikipedia.org/wiki/Kurtosis).
|
||||
`covariance` | A measure of the joint variability between two fields. A positive value means their values move in the same direction and vice versa.
|
||||
`correlation` | A measure of the strength of the relationship between two fields. The valid values are between [-1, 1]. A value of -1 means that the value is negatively correlated and a value of 1 means that it's positively correlated. A value of 0 means that there's no identifiable relationship between them.
|
||||
|
||||
## percentile, percentile_ranks
|
||||
|
||||
Percentile is the percentage of the data that's at or below a certain threshold value.
|
||||
|
||||
The `percentile` metric is a multi-value metric aggregation that lets you find outliers in your data or figure out the distribution of your data.
|
||||
|
||||
Like the `cardinality` metric, the `percentile` metric is also approximate.
|
||||
|
||||
The following example calculates the percentile in relation to the `taxful_total_price` field:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"percentile_taxful_total_price": {
|
||||
"percentiles": {
|
||||
"field": "taxful_total_price"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"percentile_taxful_total_price" : {
|
||||
"values" : {
|
||||
"1.0" : 21.984375,
|
||||
"5.0" : 27.984375,
|
||||
"25.0" : 44.96875,
|
||||
"50.0" : 64.22061688311689,
|
||||
"75.0" : 93.0,
|
||||
"95.0" : 156.0,
|
||||
"99.0" : 222.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Percentile rank is the percentile of values at or below a threshold grouped by a specified value. For example, if a value is greater than or equal to 80% of the values, it has a percentile rank of 80.
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"percentile_rank_taxful_total_price": {
|
||||
"percentile_ranks": {
|
||||
"field": "taxful_total_price",
|
||||
"values": [
|
||||
10,
|
||||
15
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"percentile_rank_taxful_total_price" : {
|
||||
"values" : {
|
||||
"10.0" : 0.055096056411283456,
|
||||
"15.0" : 0.0830092961834656
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## geo_bound
|
||||
|
||||
The `geo_bound` metric is a multi-value metric aggregation that calculates the bounding box in terms of latitude and longitude around a `geo_point` field.
|
||||
|
||||
The following example returns the `geo_bound` metrics for the `geoip.location` field:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"geo": {
|
||||
"geo_bounds": {
|
||||
"field": "geoip.location"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
"aggregations" : {
|
||||
"geo" : {
|
||||
"bounds" : {
|
||||
"top_left" : {
|
||||
"lat" : 52.49999997206032,
|
||||
"lon" : -118.20000001229346
|
||||
},
|
||||
"bottom_right" : {
|
||||
"lat" : 4.599999985657632,
|
||||
"lon" : 55.299999956041574
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## top_hits
|
||||
|
||||
The `top_hits` metric is a multi-value metric aggregation that ranks the matching documents based on a relevance score for the field that's being aggregated.
|
||||
|
||||
You can specify the following options:
|
||||
|
||||
- `from`: The starting position of the hit.
|
||||
- `size`: The maximum size of hits to return. The default value is 3.
|
||||
- `sort`: How the matching hits are sorted. By default, the hits are sorted by the relevance score of the aggregation query.
|
||||
|
||||
The following example returns the top 5 products in your eCommerce data:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_ecommerce/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"top_hits_products": {
|
||||
"top_hits": {
|
||||
"size": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"top_hits_products" : {
|
||||
"hits" : {
|
||||
"total" : {
|
||||
"value" : 4675,
|
||||
"relation" : "eq"
|
||||
},
|
||||
"max_score" : 1.0,
|
||||
"hits" : [
|
||||
{
|
||||
"_index" : "opensearch_dashboards_sample_data_ecommerce",
|
||||
"_type" : "_doc",
|
||||
"_id" : "glMlwXcBQVLeQPrkHPtI",
|
||||
"_score" : 1.0,
|
||||
"_source" : {
|
||||
"category" : [
|
||||
"Women's Accessories",
|
||||
"Women's Clothing"
|
||||
],
|
||||
"currency" : "EUR",
|
||||
"customer_first_name" : "rania",
|
||||
"customer_full_name" : "rania Evans",
|
||||
"customer_gender" : "FEMALE",
|
||||
"customer_id" : 24,
|
||||
"customer_last_name" : "Evans",
|
||||
"customer_phone" : "",
|
||||
"day_of_week" : "Sunday",
|
||||
"day_of_week_i" : 6,
|
||||
"email" : "rania@evans-family.zzz",
|
||||
"manufacturer" : [
|
||||
"Tigress Enterprises"
|
||||
],
|
||||
"order_date" : "2021-02-28T14:16:48+00:00",
|
||||
"order_id" : 583581,
|
||||
"products" : [
|
||||
{
|
||||
"base_price" : 10.99,
|
||||
"discount_percentage" : 0,
|
||||
"quantity" : 1,
|
||||
"manufacturer" : "Tigress Enterprises",
|
||||
"tax_amount" : 0,
|
||||
"product_id" : 19024,
|
||||
"category" : "Women's Accessories",
|
||||
"sku" : "ZO0082400824",
|
||||
"taxless_price" : 10.99,
|
||||
"unit_discount_amount" : 0,
|
||||
"min_price" : 5.17,
|
||||
"_id" : "sold_product_583581_19024",
|
||||
"discount_amount" : 0,
|
||||
"created_on" : "2016-12-25T14:16:48+00:00",
|
||||
"product_name" : "Snood - white/grey/peach",
|
||||
"price" : 10.99,
|
||||
"taxful_price" : 10.99,
|
||||
"base_unit_price" : 10.99
|
||||
},
|
||||
{
|
||||
"base_price" : 32.99,
|
||||
"discount_percentage" : 0,
|
||||
"quantity" : 1,
|
||||
"manufacturer" : "Tigress Enterprises",
|
||||
"tax_amount" : 0,
|
||||
"product_id" : 19260,
|
||||
"category" : "Women's Clothing",
|
||||
"sku" : "ZO0071900719",
|
||||
"taxless_price" : 32.99,
|
||||
"unit_discount_amount" : 0,
|
||||
"min_price" : 17.15,
|
||||
"_id" : "sold_product_583581_19260",
|
||||
"discount_amount" : 0,
|
||||
"created_on" : "2016-12-25T14:16:48+00:00",
|
||||
"product_name" : "Cardigan - grey",
|
||||
"price" : 32.99,
|
||||
"taxful_price" : 32.99,
|
||||
"base_unit_price" : 32.99
|
||||
}
|
||||
],
|
||||
"sku" : [
|
||||
"ZO0082400824",
|
||||
"ZO0071900719"
|
||||
],
|
||||
"taxful_total_price" : 43.98,
|
||||
"taxless_total_price" : 43.98,
|
||||
"total_quantity" : 2,
|
||||
"total_unique_products" : 2,
|
||||
"type" : "order",
|
||||
"user" : "rani",
|
||||
"geoip" : {
|
||||
"country_iso_code" : "EG",
|
||||
"location" : {
|
||||
"lon" : 31.3,
|
||||
"lat" : 30.1
|
||||
},
|
||||
"region_name" : "Cairo Governorate",
|
||||
"continent_name" : "Africa",
|
||||
"city_name" : "Cairo"
|
||||
},
|
||||
"event" : {
|
||||
"dataset" : "sample_ecommerce"
|
||||
}
|
||||
}
|
||||
...
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## scripted_metric
|
||||
|
||||
The `scripted_metric` metric is a multi-value metric aggregation that returns metrics calculated from a specified script.
|
||||
|
||||
A script has four stages: the initial stage, the map stage, the combine stage, and the reduce stage.
|
||||
|
||||
* `init_script`: (OPTIONAL) Sets the initial state and executes before any collection of documents.
|
||||
* `map_script`: Checks the value of the `type` field and executes the aggregation on the collected documents.
|
||||
* `combine_script`: Aggregates the state returned from every shard. The aggregated value is returned to the coordinating node.
|
||||
* `reduce_script`: Provides access to the variable states; this variable combines the results from the `combine_script` on each shard into an array.
|
||||
|
||||
The following example aggregates the different HTTP response types in web log data:
|
||||
|
||||
```json
|
||||
GET opensearch_dashboards_sample_data_logs/_search
|
||||
{
|
||||
"size": 0,
|
||||
"aggregations": {
|
||||
"responses.counts": {
|
||||
"scripted_metric": {
|
||||
"init_script": "state.responses = ['error':0L,'success':0L,'other':0L]",
|
||||
"map_script": """
|
||||
def code = doc['response.keyword'].value;
|
||||
if (code.startsWith('5') || code.startsWith('4')) {
|
||||
state.responses.error += 1 ;
|
||||
} else if(code.startsWith('2')) {
|
||||
state.responses.success += 1;
|
||||
} else {
|
||||
state.responses.other += 1;
|
||||
}
|
||||
""",
|
||||
"combine_script": "state.responses",
|
||||
"reduce_script": """
|
||||
def counts = ['error': 0L, 'success': 0L, 'other': 0L];
|
||||
for (responses in states) {
|
||||
counts.error += responses['error'];
|
||||
counts.success += responses['success'];
|
||||
counts.other += responses['other'];
|
||||
}
|
||||
return counts;
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Sample Response
|
||||
|
||||
```json
|
||||
...
|
||||
"aggregations" : {
|
||||
"responses.counts" : {
|
||||
"value" : {
|
||||
"other" : 0,
|
||||
"success" : 12832,
|
||||
"error" : 1242
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue