elasticsearch 如何在OpenSearch SQL插件中使用提取大小?

qxsslcnc  于 2023-03-17  发布在  ElasticSearch
关注(0)|答案(1)|浏览(164)

OpenSearch文档说fetch_size是受支持的,应该可以工作。但是,这在OpenSearch 2. 5. 3中肯定不适合我。

查询1:

POST _plugins/_sql/
{
  "query" : "SELECT start_time FROM my_opensearch_index"
}

答复1:

{
  "schema": [
    {
      "name": "start_time",
      "type": "timestamp"
    }
  ],
  "datarows": [
    [
      "2022-12-01 02:46:18.406516529"
    ],
    [
      "2022-12-01 02:46:15.83386667"
    ],
...
],
    [
      "2022-12-01 02:57:49.658765135"
    ]
  ],
  "total": 200,
  "size": 200,
  "status": 200
}

200似乎是SQL查询的默认值size。但是,当我尝试以下查询时:

查询2:

POST _plugins/_sql/
{
  "fetch_size" : 5,
  "query" : "SELECT start_time FROM my_opensearch_index"
}

答复2:

{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "Index type [my_opensearch_index] does not exist",
    "type": "IllegalArgumentException"
  },
  "status": 500
}

注意,Query 2中唯一的变化是在查询中添加了"fetch_size" : 5,
注:这是在OpenSearch 2.5.3上完成的;我还没有在ElasticSearch上尝试过这个,我知道他们有一个类似的功能。

vlf7wbxs

vlf7wbxs1#

尝试在FROM子句中使用索引名称,而不是索引别名。
在这种情况下,正确索引别名are not handled

相关问题