Protocol

The PPL plugin provides responses in JDBC format. The JDBC format is widely used because it provides schema information and more functionality such as pagination. Besides JDBC driver, various clients can benefit from the detailed and well formatted response.

Response Format

The body of HTTP POST request can take a few more additional fields with the PPL query:

  1. curl -H 'Content-Type: application/json' -X POST localhost:9200/_plugins/_ppl \
  2. ... -d '{"query" : "source=accounts | fields firstname, lastname"}'

The following example shows a normal response where the schema includes a field name and its type and datarows includes the result set:

  1. {
  2. "schema": [
  3. {
  4. "name": "firstname",
  5. "type": "string"
  6. },
  7. {
  8. "name": "lastname",
  9. "type": "string"
  10. }
  11. ],
  12. "datarows": [
  13. [
  14. "Amber",
  15. "Duke"
  16. ],
  17. [
  18. "Hattie",
  19. "Bond"
  20. ],
  21. [
  22. "Nanette",
  23. "Bates"
  24. ],
  25. [
  26. "Dale",
  27. "Adams"
  28. ]
  29. ],
  30. "total": 4,
  31. "size": 4
  32. }

If any error occurred, error message and the cause will be returned instead:

  1. curl -H 'Content-Type: application/json' -X POST localhost:9200/_plugins/_ppl \
  2. ... -d '{"query" : "source=unknown | fields firstname, lastname"}'
  3. {
  4. "error": {
  5. "reason": "Error occurred in OpenSearch engine: no such index [unknown]",
  6. "details": "org.opensearch.index.IndexNotFoundException: no such index [unknown]\nFor more details, please send request for Json format to see the raw response from opensearch engine.",
  7. "type": "IndexNotFoundException"
  8. },
  9. "status": 404
  10. }