-
Notifications
You must be signed in to change notification settings - Fork 102
Intro, basic queries, delete, cli, odbc #202
Conversation
docs/sql/index.md
Outdated
```sql | ||
SELECT * | ||
FROM accounts | ||
WHERE _id = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I missing something, or is Amber indexed above with an ID of 1 in your _bulk statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, changed "_id = 1".
|
||
```json | ||
PUT accounts/_bulk?refresh | ||
{"index":{"_id":"1"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's this data from? Just curious. If there's a reference here, I'm not catching it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sample data is from here - https://github.com/opendistro-for-elasticsearch/sql/blob/master/src/test/resources/doctest/testdata/accounts.json.
docs/sql/index.md
Outdated
|
||
### Search and aggregate data | ||
|
||
Use the `SELECT` clause along with `FROM`, `WHERE`, `GROUP BY`, `HAVING`, `ORDER BY`, and `LIMIT` to search and aggregate data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clause, along with
docs/sql/index.md
Outdated
|
||
Use the `SELECT` clause along with `FROM`, `WHERE`, `GROUP BY`, `HAVING`, `ORDER BY`, and `LIMIT` to search and aggregate data. | ||
|
||
Among these clauses, `SELECT` and `FROM` are required, as they specify which fields to retrieve and which indices to retrieve them from. All other clauses are optional and you can use them according to your requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are optional. Use them according to your needs.
docs/sql/index.md
Outdated
@@ -56,8 +56,375 @@ When you return data in CSV or raw format, each row corresponds to a *document*, | |||
|
|||
## User interfaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's mention right at the top that, y'know, we have a UI now, it's good for use cases X and Y, and include a screenshot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashwinkumar12345 Could you help change the GET
request above to the correspondent POST
request? Because we're removing GET
endpoint very soon due to security concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion but a POST
request should look like the sample call here: https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/sql-support.html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
docs/sql/index.md
Outdated
```sql | ||
GET https://<host>:<port>/_opendistro/_sql?sql=select * from my-index limit 50 | ||
POST _opendistro/_sql?sql=select * from my-index limit 50 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GET
endpoint is removed already due to security concern in opendistro-for-elasticsearch/sql#414. And POST
request requires SQL query present in request body rather than URL parameter. Could you help remove it from the documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed. Please review.
|
||
- `endpoint`: You do not need to specify an option, anything that follows the launch command `odfesql` is considered as the endpoint. If you do not provide an endpoint, by default, the SQL CLI connects to http://localhost:9200. | ||
- `-u/-w`: Supports username and password for HTTP basic authentication, such as with the security plugin or fine-grained access control for Amazon Elasticsearch Service. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing an auth option here --aws-auth
.
"--aws-auth: turn on to use AWS sigV4 authentication. It can be configured by AWS CLI aws configure
command. If provided with this option, ODFE SQL CLI will try to retrieve local aws configuration to authenticate and connect"
Basically, this option is only needed when user connects to Amazon Elasticsearch endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be --aws-auth
.
"size": 5, | ||
"status": 200 | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the following to make cursor protocol complete.
To fetch subsequent pages, use the cursor
from last response
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql -d '{
"cursor": "d:eyJhIjp7fSwicyI6IkRYRjFaWEo1UVc1a1JtVjBZMmdCQUFBQUFBQUFBQU1XZWpkdFRFRkZUMlpTZEZkeFdsWnJkRlZoYnpaeVVRPT0iLCJjIjpbeyJuYW1lIjoiZmlyc3RuYW1lIiwidHlwZSI6InRleHQifSx7Im5hbWUiOiJsYXN0bmFtZSIsInR5cGUiOiJ0ZXh0In1dLCJmIjo1LCJpIjoiYWNjb3VudHMiLCJsIjo5NTF9"
}'
The result will only have fetch_size
number of datarows
and cursor
. The last page will have only datarows
and no cursor
. The datarows
can have more than fetch_size
number of records in case the nested fields are flattened.
{
"cursor": "d:eyJhIjp7fSwicyI6IkRYRjFaWEo1UVc1a1JtVjBZMmdCQUFBQUFBQUFBQU1XZWpkdFRFRkZUMlpTZEZkeFdsWnJkRlZoYnpaeVVRPT0iLCJjIjpbeyJuYW1lIjoiZmlyc3RuYW1lIiwidHlwZSI6InRleHQifSx7Im5hbWUiOiJsYXN0bmFtZSIsInR5cGUiOiJ0ZXh0In1dLCJmIjo1LCJpIjoiYWNjb3VudHMabcde12345",
"datarows": [
[
"Abbas",
"Hussain"
],
[
"Chen",
"Dai"
],
[
"Anirudha",
"Jadhav"
],
[
"Peng",
"Huo"
],
[
"John",
"Doe"
]
]
}
The cursor context is automatically cleared on the last page. To explicitly clear the cursor context use _opendistro/_sql/close
endpoint.
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql/close -d '{
"cursor": "d:eyJhIjp7fSwicyI6IkRYRjFaWEo1UVc1a1JtVjBZMmdCQUFBQUFBQUFBQU1XZWpkdFRFRkZUMlpTZEZkeFdsWnJkRlZoYnpaeVVRPT0iLCJjIjpbeyJuYW1lIjoiZmlyc3RuYW1lIiwidHlwZSI6InRleHQifSx7Im5hbWUiOiJsYXN0bmFtZSIsInR5cGUiOiJ0ZXh0In1dLCJmIjo1LCJpIjoiYWNjb3VudHMiLCJsIjo5NTF9"
}'
Response:
{"succeeded":true}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Update documentation for ODBC
add sql limitation
Change title and hierarchy
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.