Error sql api index name with '-'

(Rendi Yusuf Azhari) #1

hello everyone..
i'm interesting in sql api in elasticsearch 6.3 but error found with index name with '-'



query sql

curl --request POST \
--url http://localhost:9200/_xpack/sql/translate \
--header 'content-type: application/json' \
--data '{
"query": "SELECT * FROM index-example",
"fetch_size": 10

error found

"error": {
	"root_cause": [
			"type": "parsing_exception",
			"reason": "line 1:20: mismatched input '-' expecting {<EOF>, ',', 'FULL', 'GROUP', 'HAVING', 'INNER', 'JOIN', 'LEFT', 'LIMIT', 'NATURAL', 'ORDER', 'RIGHT', 'WHERE'}"
	"type": "parsing_exception",
	"reason": "line 1:20: mismatched input '-' expecting {<EOF>, ',', 'FULL', 'GROUP', 'HAVING', 'INNER', 'JOIN', 'LEFT', 'LIMIT', 'NATURAL', 'ORDER', 'RIGHT', 'WHERE'}",
	"caused_by": {
		"type": "input_mismatch_exception",
		"reason": null
"status": 400 }

(Andrei Stefan) #2

Hi @rendiya,
You need to escape the index name, if the index contains "reserved" characters:

"query": "SELECT * FROM \"index-example\""

(Rendi Yusuf Azhari) #3

oke thank you,... i think in mysql don't support '-' for table name and i replace with _ and work it

(system) #4

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