Created
August 7, 2018 18:46
-
-
Save derickson/5802182673869e8553d209756a24bf1d to your computer and use it in GitHub Desktop.
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
## 1) Pull all records from index named fedeastsql | |
POST /_xpack/sql?format=txt | |
{ | |
"query": "SELECT * FROM fedeastsql" | |
} | |
## 2) List all columns and datatype of this index | |
POST /_xpack/sql?format=txt | |
{ | |
"query": "DESCRIBE fedeastsql" | |
} | |
## 3) Sort employees by start date | |
POST /_xpack/sql?format=txt | |
{ | |
"query": "SELECT * FROM fedeastsql ORDER BY start_date DESC LIMIT 10" | |
} | |
## 4) Fetch all employees that live in Virginia | |
POST /_xpack/sql?format=txt | |
{ | |
"query": "SELECT * FROM fedeastsql WHERE state = 'Virginia' " | |
} | |
## 5) Fetch all employees whose name start with the letter D | |
## Bonus) Translate SQL to Elasticsearch Query DSL | |
POST /_xpack/sql?format=txt | |
{ | |
"query": "SELECT * FROM fedeastsql WHERE first_name LIKE 'D%' " | |
} | |
POST /_xpack/sql/translate | |
{ | |
"query": "SELECT * FROM fedeastsql WHERE first_name LIKE 'D%' " | |
} | |
POST /_xpack/sql/translate | |
{ | |
"query": "SELECT * FROM fedeastsql WHERE first_name LIKE 'D%' ", | |
"fetch_size": 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment