X-pack 6.3 sql query

curl -X POST "http://localhost:9200/_xpack/sql?format=json" -H 'Content-Type: application/json' -d'
{
"query": "SELECT * FROM logstash-2018.06.28"
}
'
{"error":{"root_cause":[{"type":"parsing_exception","reason":"line 1:23: mismatched input '-' expecting {, ',', 'FULL', 'GROUP', 'HAVING', 'INNER', 'JOIN', 'LEFT', 'LIMIT', 'NATURAL', 'ORDER', 'RIGHT', 'WHERE'}"}],"type":"parsing_exception","reason":"line 1:23: mismatched input '-' expecting {, ',', 'FULL', 'GROUP', 'HAVING', 'INNER', 'JOIN', 'LEFT', 'LIMIT', 'NATURAL', 'ORDER', 'RIGHT', 'WHERE'}","caused_by":{"type":"input_mismatch_exception","reason":null}},"status":400}

You can not use escape( \ ).
why ?

Hi

Since the index name contains reserved SQL characters (-), you need to escape the index name. Try

curl -X POST "http://localhost:9200/_xpack/sql?format=json" -H 'Content-Type: application/json' -d'
{
"query": "SELECT * FROM \"logstash-2018.06.28\""
}
'
1 Like

Hi, Thank you for answer.

curl -X POST "http://localhost:9200/_xpack/sql?format=json" -H 'Content-Type: application/json' -d'
{
"query": "SELECT * FROM "logstash-2018.06.28""
}
'

{
"error": {
"root_cause": [
{
"type": "sql_illegal_argument_exception",
"reason": "Arrays (returned by [tags]) are not supported"
}
],
"type": "sql_illegal_argument_exception",
"reason": "Arrays (returned by [tags]) are not supported"
},
"status": 500
}

why ?

Please use :

"query": "SELECT * FROM \"logstash-2018.06.28\""

and not

"query": "SELECT * FROM "logstash-2018.06.28""

mind the \ escaping the " in your POST body.

Sorry I wrote wrong.
You can not use escape.

curl -X POST "http://localhost:9200/_xpack/sql?format=json" -H 'Content-Type: application/json' -d'
{
"query": "SELECT * FROM "logstash-2018.06.28""
}
'

response error
{
"error": {
"root_cause": [
{
"type": "sql_illegal_argument_exception",
"reason": "Arrays (returned by [tags]) are not supported"
}
],
"type": "sql_illegal_argument_exception",
"reason": "Arrays (returned by [tags]) are not supported"
},
"status": 500
}

Thank, Resolved.
The index of today's date should not be.

Also, regarding the error about arrays - Elasticsearch SQL doesn't support them at the moment.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.