-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOC] Add new documentation about Query Workbench (#5378)
* Rewrite Query Workbench --------- Signed-off-by: Melissa Vagi <[email protected]> Signed-off-by: Fanit Kolchina <[email protected]> Co-authored-by: kolchfa-aws <[email protected]> Co-authored-by: Fanit Kolchina <[email protected]>
- Loading branch information
1 parent
eb207b3
commit 32a1af4
Showing
14 changed files
with
156 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
layout: default | ||
title: Query Workbench | ||
nav_order: 125 | ||
redirect_from: | ||
- /search-plugins/sql/workbench/ | ||
--- | ||
|
||
# Query Workbench | ||
|
||
Query Workbench is a tool within OpenSearch Dashboards. You can use Query Workbench to run on-demand [SQL]({{site.url}}{{site.baseurl}}/search-plugins/sql/sql/index/) and [PPL]({{site.url}}{{site.baseurl}}/search-plugins/sql/ppl/index/) queries, translate queries into their equivalent REST API calls, and view and save results in different [response formats]({{site.url}}{{site.baseurl}}/search-plugins/sql/response-formats/). | ||
|
||
A view of the Query Workbench interface within OpenSearch Dashboards is shown in the following image. | ||
|
||
<img src="{{site.url}}{{site.baseurl}}/images/dashboards/query-workbench-ui.png" alt="Query Workbench interface within OpenSearch Dashboards" width="700"> | ||
|
||
## Prerequisites | ||
|
||
Before getting started, make sure you have [indexed your data]({{site.url}}{{site.baseurl}}/im-plugin/index/). | ||
|
||
For this tutorial, you can index the following sample documents. Alternatively, you can use the [OpenSearch Playground](https://playground.opensearch.org/app/opensearch-query-workbench#/), which has preloaded indexes that you can use to try out Query Workbench. | ||
|
||
To index sample documents, send the following [Bulk API]({{site.url}}{{site.baseurl}}/api-reference/document-apis/bulk/) request: | ||
|
||
```json | ||
PUT accounts/_bulk?refresh | ||
{"index":{"_id":"1"}} | ||
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"[email protected]","city":"Brogan","state":"IL"} | ||
{"index":{"_id":"6"}} | ||
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"[email protected]","city":"Dante","state":"TN"} | ||
{"index":{"_id":"13"}} | ||
{"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","email":"[email protected]","city":"Nogal","state":"VA"} | ||
{"index":{"_id":"18"}} | ||
{"account_number":18,"balance":4180,"firstname":"Dale","lastname":"Adams","age":33,"gender":"M","address":"467 Hutchinson Court","email":"[email protected]","city":"Orick","state":"MD"} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Running SQL queries within Query Workbench | ||
|
||
Follow these steps to learn how to run SQL queries against your OpenSearch data using Query Workbench: | ||
|
||
1. Access Query Workbench. | ||
- To access Query Workbench, go to OpenSearch Dashboards and choose **OpenSearch Plugins** > **Query Workbench** from the main menu. | ||
|
||
2. Run a query. | ||
- Select the **SQL** button. In the query editor, type a SQL expression and then select the **Run** button to run the query. | ||
|
||
The following example query retrieves the first name, last name, and balance from the `accounts` index for accounts with a balance greater than 10,000 and sorts by balance in descending order: | ||
|
||
```sql | ||
SELECT | ||
firstname, | ||
lastname, | ||
balance | ||
FROM | ||
accounts | ||
WHERE | ||
balance > 10000 | ||
ORDER BY | ||
balance DESC; | ||
``` | ||
{% include copy.html %} | ||
|
||
3. View the results. | ||
- View the results in the **Results** pane, which presents the query output in tabular format. You can filter and download the results as needed. | ||
|
||
The following image shows the query editor pane and results pane for the preceding SQL query: | ||
|
||
<img src="{{site.url}}{{site.baseurl}}/images/dashboards/query-workbench-query-step2.png" alt="Query Workbench SQL query input and results output panes" width="800"> | ||
|
||
4. Clear the query editor. | ||
- Select the **Clear** button to clear the query editor and run a new query. | ||
|
||
5. Examine how the query is processed. | ||
- Select the **Explain** button to examine how OpenSearch processes the query, including the steps involved and order of operations. | ||
|
||
The following image shows the explanation of the SQL query that was run in step 2. | ||
|
||
<img src="{{site.url}}{{site.baseurl}}/images/dashboards/query-explain.png" alt="Query Workbench SQL query explanation pane" width="500"> | ||
|
||
## Running PPL queries within Query Workbench | ||
|
||
Follow these steps to learn how to run PPL queries against your OpenSearch data using Query Workbench: | ||
|
||
1. Access Query Workbench. | ||
- To access Query Workbench, go to OpenSearch Dashboards and choose **OpenSearch Plugins** > **Query Workbench** from the main menu. | ||
|
||
2. Run a query. | ||
- Select the **PPL** button. In the query editor, type a PPL query and then select the **Run** button to run the query. | ||
|
||
The following is an example query that retrieves the `firstname` and `lastname` fields for documents in the `accounts` index with age greater than `18`: | ||
|
||
```sql | ||
search source=accounts | ||
| where age > 18 | ||
| fields firstname, lastname | ||
``` | ||
{% include copy.html %} | ||
|
||
3. View the results. | ||
- View the results in the **Results** pane, which presents the query output in tabular format. | ||
|
||
The following image shows the query editor pane and results pane for the PPL query that was run in step 2: | ||
|
||
<img src="{{site.url}}{{site.baseurl}}/images/dashboards/query-workbench-ppl.png" alt="Query Workbench PPL query input and results output panes"> | ||
|
||
4. Clear the query editor. | ||
- Select the **Clear** button to clear the query editor and run a new query. | ||
|
||
5. Examine how the query is processed. | ||
- Select the **Explain** button to examine how OpenSearch processes the query, including the steps involved and order of operations. | ||
|
||
The following image shows the explanation of the PPL query that was run in step 2. | ||
|
||
<img src="{{site.url}}{{site.baseurl}}/images/dashboards/query-PPL-explain.png" alt="Query Workbench PPL query explanation pane" width="500"> | ||
|
||
Query Workbench does not support delete or update operations through SQL or PPL. Access to data is read-only. | ||
{: .important} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
layout: default | ||
title: PPL – Piped Processing Language | ||
title: PPL | ||
parent: SQL and PPL | ||
nav_order: 5 | ||
has_children: true | ||
|
@@ -14,53 +14,34 @@ redirect_from: | |
- /search-plugins/ppl/protocol/ | ||
--- | ||
|
||
# PPL – Piped Processing Language | ||
# PPL | ||
|
||
Piped Processing Language (PPL) is a query language that lets you use pipe (`|`) syntax to explore, discover, and query data stored in OpenSearch. | ||
Piped Processing Language (PPL) is a query language that focuses on processing data in a sequential, step-by-step manner. PPL uses the pipe (`|`) operator to combine commands to find and retrieve data. It is the primary language used with observability in OpenSearch and supports multi-data queries. | ||
|
||
To quickly get up and running with PPL, use **Query Workbench** in OpenSearch Dashboards. To learn more, see [Workbench]({{site.url}}{{site.baseurl}}/search-plugins/sql/workbench/). | ||
## PPL syntax | ||
|
||
The PPL syntax consists of commands delimited by the pipe character (`|`) where data flows from left to right through each pipeline. | ||
The following example shows the basic PPL syntax: | ||
|
||
```sql | ||
search command | command 1 | command 2 ... | ||
search source=<index-name> | <command_1> | <command_2> | ... | <command_n> | ||
``` | ||
{% include copy.html %} | ||
|
||
You can only use read-only commands like `search`, `where`, `fields`, `rename`, `dedup`, `stats`, `sort`, `eval`, `head`, `top`, and `rare`. | ||
See [Syntax]({{site.url}}{{site.baseurl}}/search-plugins/sql/ppl/syntax/) for specific PPL syntax examples. | ||
|
||
## Quick start | ||
## PPL commands | ||
|
||
To get started with PPL, choose **Dev Tools** in OpenSearch Dashboards and use the `bulk` operation to index some sample data: | ||
PPL filters, transforms, and aggregates data using a series of commands. See [Commands](/search-plugins/sql/ppl/functions/) for a description and an example of each command. | ||
|
||
```json | ||
PUT accounts/_bulk?refresh | ||
{"index":{"_id":"1"}} | ||
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"[email protected]","city":"Brogan","state":"IL"} | ||
{"index":{"_id":"6"}} | ||
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"[email protected]","city":"Dante","state":"TN"} | ||
{"index":{"_id":"13"}} | ||
{"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","city":"Nogal","state":"VA"} | ||
{"index":{"_id":"18"}} | ||
{"account_number":18,"balance":4180,"firstname":"Dale","lastname":"Adams","age":33,"gender":"M","address":"467 Hutchinson Court","email":"[email protected]","city":"Orick","state":"MD"} | ||
``` | ||
|
||
Go to **Query Workbench** and select **PPL**. | ||
|
||
The following example returns `firstname` and `lastname` fields for documents in an `accounts` index with `age` greater than 18: | ||
## Using PPL within OpenSearch | ||
|
||
```sql | ||
search source=accounts | ||
| where age > 18 | ||
| fields firstname, lastname | ||
``` | ||
To use PPL, you must have installed OpenSearch Dashboards. PPL is available within the [Query Workbench tool](https://playground.opensearch.org/app/opensearch-query-workbench#/). See the [Query Workbench]({{site.url}}{{site.baseurl}}/dashboards/query-workbench/) documentation for a tutorial on using PPL within OpenSearch. | ||
|
||
#### Example response | ||
## Developer documentation | ||
|
||
firstname | lastname | | ||
:--- | :--- | | ||
Amber | Duke | ||
Hattie | Bond | ||
Nanette | Bates | ||
Dale | Adams | ||
Developers can find information in the following resources: | ||
|
||
![PPL query workbench]({{site.url}}{{site.baseurl}}/images/ppl.png) | ||
- [Piped Processing Language](https://github.com/opensearch-project/piped-processing-language) specification | ||
- [OpenSearch PPL Reference Manual](https://github.com/opensearch-project/sql/blob/main/docs/user/ppl/index.rst) | ||
- [Observability](https://github.com/opensearch-project/dashboards-observability/) using [PPL-based visualizations](https://github.com/opensearch-project/dashboards-observability#event-analytics) | ||
- PPL [Data Types](https://github.com/opensearch-project/sql/blob/main/docs/user/ppl/general/datatypes.rst) |
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 was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.