0

I'm running this code and I'm getting this error and I just can't figure out what's wrong with it:

POST /_sql/translate
{
  "query": "SELECT duracao, elementoRede, hostname, ingest_time FROM reta-* WHERE duracao > 0 ORDER BY duracao DESC LIMIT 10",
  "fetch_size": 100
}

1 Answers1

2

You need to escape the special character, try this

POST /_sql/translate
{
  "query": "SELECT duracao, elementoRede, hostname, ingest_time FROM \"reta-*\" WHERE duracao > 0 ORDER BY duracao DESC LIMIT 10",
  "fetch_size": 100
}
Nishikant Tayade
  • 483
  • 3
  • 12
  • This was what was needed!! Thank you very much sir! – sirvictahh Mar 18 '22 at 10:48
  • Another thing, is there a way to select a DISTINCT element in the Elasticseatch sql? For example: SELECT DISTINCT elementoRede FROM "reta-*" ? – sirvictahh Mar 18 '22 at 10:54
  • @sirvictahh AFAIK, DISTINCT function is not available on SQL supported function for Elasticsearch. Check all available function here [SHOW FUNCTIONS](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-show-functions.html), also check this [Elasticsearch Select Distinct](https://stackoverflow.com/questions/40381339/how-to-do-an-elasticsearch-select-distinct) – Nishikant Tayade Mar 18 '22 at 12:30