SQL Query not executing

Hello, i have index names as alpha-* and when i try to run SQL query on the index it throws error
POST /_xpack/sql?format=txt
{
"query": "SELECT * FROM alpha-* "
}

error :-1:
"type": "parsing_exception",
"reason": "line 1:20: mismatched input '-' expecting {, ',', 'ANALYZE', 'ANALYZED', 'AS', 'CATALOGS', 'COLUMNS', 'CURRENT_DATE', 'CURRENT_TIMESTAMP', 'DAY', 'DEBUG', 'EXECUTABLE', 'EXPLAIN', 'FIRST', 'FORMAT', 'FULL', 'FUNCTIONS', 'GRAPHVIZ', 'GROUP', 'HAVING', 'HOUR', 'INNER', 'INTERVAL', 'JOIN', 'LAST', 'LEFT', 'LIMIT', 'MAPPED', 'MINUTE', 'MONTH', 'NATURAL', 'OPTIMIZED', 'ORDER', 'PARSED', 'PHYSICAL', 'PLAN', 'RIGHT', 'RLIKE', 'QUERY', 'SCHEMAS', 'SECOND', 'SHOW', 'SYS', 'TABLES', 'TEXT', 'TYPE', 'TYPES', 'VERIFY', 'WHERE', 'YEAR', '{LIMIT', IDENTIFIER, DIGIT_IDENTIFIER, QUOTED_IDENTIFIER, BACKQUOTED_IDENTIFIER}"

Try with

"query": "SELECT * FROM \"alpha-*\" "

Thanks... That worked like a charm :slight_smile:

Just wanted to know for my understanding why do we escape those by " ? any reason ?

See https://www.elastic.co/guide/en/elasticsearch/reference/7.2/sql-index-patterns.html#sql-index-patterns-multi

Also, https://www.elastic.co/guide/en/elasticsearch/reference/7.2/sql-lexical-structure.html#sql-syntax-single-vs-double-quotes.

Thanks That Helped

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