Home > front end >  elasticsearch SQL query in python
elasticsearch SQL query in python

Time:09-02

elasticsearch == 7.16.1

Trying to run a very simple query just to try out the SQL implementation w/python.

es.sql.query(body={'query':'select * from index_name-* limit 100'})

Getting this error:

RequestError: RequestError(400, 'parsing_exception', "line 1:32: mismatched input '*' expecting {<EOF>, ',', 'ANALYZE', 'ANALYZED', 'AS', 'CATALOGS', 'COLUMNS', 'CURRENT_DATE', 'CURRENT_TIME', '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', 'PIVOT', 'PLAN', 'RIGHT', 'RLIKE', 'QUERY', 'SCHEMAS', 'SECOND', 'SHOW', 'SYS', 'TABLES', 'TEXT', 'TOP', 'TYPE', 'TYPES', 'VERIFY', 'WHERE', 'YEAR', LIMIT_ESC, IDENTIFIER, DIGIT_IDENTIFIER, QUOTED_IDENTIFIER, BACKQUOTED_IDENTIFIER}")

So I think it doesn't like : index_name-*

Ive tried a few variations: index_name index_name*

But if I don't include the * how do I get all the dates of the indexes if I want to search across all of them?

CodePudding user response:

Try this:

POST _sql?format=txt
{
  "query": "SELECT * FROM \"index_name-*\""
}
  • Related