【问题标题】:ElasticSearch: Opendistro SQL: Failed to parse query due to offending symbol [.11]ElasticSearch:Opendistro SQL:由于违规符号而无法解析查询 [.11]
【发布时间】:2021-02-23 18:10:58
【问题描述】:

我有一个 ElasticSearch 索引,其名称为 .(例如:my_index-2020.11.06-001)。当我使用 SQL 获取所有文档的count 时,出现以下错误

curl --location --request POST '127.0.0.1:9200/_opendistro/_sql' 
--header 'Content-Type: application/json'
--data-raw '{
  "query": "SELECT count(*) FROM my_index-2020.11.06-001"
}'

Failed to parse query due to offending symbol [.11] at: 'SELECT count(*) FROM my_index-2020.11.06-001 ...

我也尝试在索引名称中使用反引号 (`) 和单引号 ('),但这也无济于事

curl --location --request POST '127.0.0.1:9200/_opendistro/_sql' 
--header 'Content-Type: application/json'
--data-raw '{
  "query": "SELECT count(*) FROM `my_index-2020.11.06-001`"
}'

{
  "error": {
    "reason": "Invalid SQL query",
    "details": "Field [my_index-2020.11.06-001] cannot be found or used here.",
    "type": "SemanticAnalysisException"
    ...

还有其他方法可以解决这个问题吗?

【问题讨论】:

    标签: elasticsearch aws-elasticsearch elasticsearch-opendistro


    【解决方案1】:

    这是一个错误,但有一个解决方法 禁用语义分析器

    curl --location --request PUT 'http://localhost:9200/_cluster/settings' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "transient": {
            "opendistro.sql.query.analysis.enabled": "false"
        }
    }'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-06
      • 2022-11-25
      • 1970-01-01
      • 1970-01-01
      • 2018-11-11
      • 1970-01-01
      • 1970-01-01
      • 2019-09-26
      相关资源
      最近更新 更多