## 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