Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit c6a697a

Browse files
committed
Use fenced code block
1 parent f1eba13 commit c6a697a

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

docs/sql/endpoints.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ You can send HTTP GET request with your query embedded in URL parameter.
3636

3737
SQL query:
3838

39+
```console
3940
>> curl -H 'Content-Type: application/json' -X GET localhost:9200/_opendistro/_sql?sql=SELECT * FROM accounts
41+
```
4042

4143
## POST
4244

@@ -48,9 +50,11 @@ You can also send HTTP POST request with your query in request body.
4850

4951
SQL query:
5052

53+
```console
5154
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql -d '{
5255
"query" : "SELECT * FROM accounts"
5356
}'
57+
```
5458

5559
## Explain
5660

@@ -65,12 +69,15 @@ directly.
6569

6670
Explain query:
6771

72+
```console
6873
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql/_explain -d '{
6974
"query" : "SELECT firstname, lastname FROM accounts WHERE age > 20"
7075
}'
76+
```
7177

7278
Explain:
7379

80+
```json
7481
{
7582
"from" : 0,
7683
"size" : 200,
@@ -109,3 +116,4 @@ Explain:
109116
"excludes" : [ ]
110117
}
111118
}
119+
```

docs/sql/monitoring.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ The meaning of fields in the response is as follows:
4343

4444
SQL query:
4545

46+
```console
4647
>> curl -H 'Content-Type: application/json' -X GET localhost:9200/_opendistro/_sql/stats
48+
```
4749

4850
Result set:
4951

52+
```json
5053
{
5154
"failed_request_count_cb" : 0,
5255
"failed_request_count_cuserr" : 0,
@@ -55,3 +58,4 @@ Result set:
5558
"request_count" : 0,
5659
"failed_request_count_syserr" : 0
5760
}
61+
```

docs/sql/protocol.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Elasticsearch DSL directly.
3838

3939
SQL query:
4040

41+
```console
4142
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql -d '{
4243
"query" : "SELECT firstname, lastname, balance FROM accounts",
4344
"filter" : {
@@ -48,9 +49,11 @@ SQL query:
4849
}
4950
}
5051
}'
52+
```
5153

5254
Explain:
5355

56+
```json
5457
{
5558
"from" : 0,
5659
"size" : 200,
@@ -90,6 +93,7 @@ Explain:
9093
"excludes" : [ ]
9194
}
9295
}
96+
```
9397

9498
### Example 2
9599

@@ -98,6 +102,7 @@ in prepared SQL query.
98102

99103
SQL query:
100104

105+
```console
101106
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql -d '{
102107
"query" : "SELECT * FROM accounts WHERE age = ?",
103108
"parameters" : [
@@ -107,9 +112,11 @@ SQL query:
107112
}
108113
]
109114
}'
115+
```
110116

111117
Explain:
112118

119+
```json
113120
{
114121
"from" : 0,
115122
"size" : 200,
@@ -138,6 +145,7 @@ Explain:
138145
}
139146
}
140147
}
148+
```
141149

142150
## Elasticsearch DSL
143151

@@ -151,12 +159,15 @@ efforts are needed to parse and interpret it.
151159

152160
SQL query:
153161

162+
```console
154163
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql -d '{
155164
"query" : "SELECT firstname, lastname, age FROM accounts ORDER BY age LIMIT 2"
156165
}'
166+
```
157167

158168
Result set:
159169

170+
```json
160171
{
161172
"_shards" : {
162173
"total" : 5,
@@ -204,6 +215,7 @@ Result set:
204215
"took" : 100,
205216
"timed_out" : false
206217
}
218+
```
207219

208220
## JDBC Format
209221

@@ -220,12 +232,15 @@ and `datarows` includes the result set.
220232

221233
SQL query:
222234

235+
```console
223236
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql?format=jdbc -d '{
224237
"query" : "SELECT firstname, lastname, age FROM accounts ORDER BY age LIMIT 2"
225238
}'
239+
```
226240

227241
Result set:
228242

243+
```json
229244
{
230245
"schema" : [
231246
{
@@ -257,6 +272,7 @@ Result set:
257272
"size" : 2,
258273
"status" : 200
259274
}
275+
```
260276

261277
### Example 2
262278

@@ -265,12 +281,15 @@ instead.
265281

266282
SQL query:
267283

284+
```console
268285
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql?format=jdbc -d '{
269286
"query" : "SELECT unknown FROM accounts"
270287
}'
288+
```
271289

272290
Result set:
273291

292+
```json
274293
{
275294
"error" : {
276295
"reason" : "Invalid SQL query",
@@ -279,6 +298,7 @@ Result set:
279298
},
280299
"status" : 400
281300
}
301+
```
282302

283303
## CSV Format
284304

@@ -290,17 +310,21 @@ You can also use CSV format to download result set as CSV.
290310

291311
SQL query:
292312

313+
```console
293314
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql?format=csv -d '{
294315
"query" : "SELECT firstname, lastname, age FROM accounts ORDER BY age"
295316
}'
317+
```
296318

297319
Result set:
298320

321+
```csv
299322
firstname,lastname,age
300323
Nanette,Bates,28
301324
Amber,Duke,32
302325
Dale,Adams,33
303326
Hattie,Bond,36
327+
```
304328

305329
## Raw Format
306330

@@ -313,13 +337,17 @@ line tool for post processing.
313337

314338
SQL query:
315339

340+
```console
316341
>> curl -H 'Content-Type: application/json' -X POST localhost:9200/_opendistro/_sql?format=raw -d '{
317342
"query" : "SELECT firstname, lastname, age FROM accounts ORDER BY age"
318343
}'
344+
```
319345

320346
Result set:
321347

348+
```
322349
Nanette|Bates|28
323350
Amber|Duke|32
324351
Dale|Adams|33
325352
Hattie|Bond|36
353+
```

0 commit comments

Comments
 (0)