getredash/redash · error · Exception
Advanced queries are not supported
Error message
Advanced queries are not supported
What it means
The legacy Elasticsearch runner only supports Lucene-style query-string searches sent as HTTP GET. If the query does not match the simple format, execution falls into the else branch of the parsing logic and raises 'Advanced queries are not supported'. Full JSON DSL queries (HTTP POST bodies) were never implemented (see the TODO in the source).
Source
Thrown at redash/query_runner/elasticsearch.py:409
if isinstance(query_data, str):
_from = 0
while True:
query_size = size if limit >= (_from + size) else (limit - _from)
self._execute_simple_query(
url + "&size={0}".format(query_size),
self.auth,
_from,
mappings,
result_fields,
result_columns,
result_rows,
)
_from += size
if _from >= limit:
break
else:
# TODO: Handle complete ElasticSearch queries (JSON based sent over HTTP POST)
raise Exception("Advanced queries are not supported")
data = {"columns": result_columns, "rows": result_rows}
except requests.HTTPError as e:
logger.exception(e)
r = e.response
error = "Failed to execute query. Return Code: {0} Reason: {1}".format(r.status_code, r.text)
data = None
except requests.exceptions.RequestException as e:
logger.exception(e)
error = "Connection refused"
data = None
return data, error
class ElasticSearch(BaseElasticSearch):
@classmethod
def enabled(cls):View on GitHub (pinned to ca79fe988d)
Solutions
- Rewrite the query as a Lucene query-string (e.g. status:active AND age:>30) instead of JSON DSL
- Switch the data source to the 'ElasticSearch (new)' / elasticsearch2 query runner, which supports JSON DSL via POST
- If stuck on the legacy runner, wrap the search in an external API and use the JSON URL query runner
Example fix
// before
{"query": {"term": {"status": "active"}}}
// after
status:active Defensive patterns
Strategy: validation
Validate before calling
import json
def is_simple_query(q: str) -> bool:
q = q.strip()
if not q:
return False
if q.startswith("{") or q.startswith("["):
try:
json.loads(q)
return False # JSON DSL not supported by legacy runner
except ValueError:
pass
return True Try / catch
try:
result, error = runner.run_query(query, user)
except Exception as e:
if "Advanced queries are not supported" in str(e):
raise UserError("Rewrite as a Lucene query string or switch to the Elasticsearch2 data source") Prevention
- Keep queries as Lucene query strings on the legacy runner
- Use elasticsearch2 data source for JSON DSL queries
- Validate query shape client-side before submitting
When it happens
Trigger: Running a query whose parsed structure is not a simple query-string search — e.g. pasting a full Elasticsearch JSON DSL body ({"query": {"bool": ...}}) or any query that the runner's naive parser cannot reduce to a query string plus pagination parameters.
Common situations: Users copying curl examples from the Elasticsearch docs into Redash, migrating from Kibana saved queries, expecting the DSL support that the newer elasticsearch2 runner has.
Related errors
- Redash failed to parse the results it got from Elasticsearch
- Failed to execute query. Return Code: {0} Reason: {1}
- Connection refused
- Redash failed to parse the results it got from Elasticsearch
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/1e2a6f5869d65312.
Report an issue: GitHub.