SQL translate API

SQL translate API

New API reference

For the most up-to-date API details, refer to SQL APIs.

Translates an SQL search into a search API request containing Query DSL. See SQL Translate API.

  1. resp = client.sql.translate(
  2. query="SELECT * FROM library ORDER BY page_count DESC",
  3. fetch_size=10,
  4. )
  5. print(resp)
  1. const response = await client.sql.translate({
  2. query: "SELECT * FROM library ORDER BY page_count DESC",
  3. fetch_size: 10,
  4. });
  5. console.log(response);
  1. POST _sql/translate
  2. {
  3. "query": "SELECT * FROM library ORDER BY page_count DESC",
  4. "fetch_size": 10
  5. }

Request

GET _sql/translate

POST _sql/translate

Prerequisites

  • If the Elasticsearch security features are enabled, you must have the read index privilege for the data stream, index, or alias you search.

Limitations

See SQL Limitations.

Request body

The SQL translate API accepts the same request body parameters as the SQL search API, excluding cursor.

Response body

The SQL translate API returns the same response body as the search API.