【问题标题】:Getting error while reading data from DSE cluster with Stargate API使用 Stargate API 从 DSE 集群读取数据时出错
【发布时间】:2021-11-26 20:43:59
【问题描述】:

由于在 Talend 中使用 cassandra 时出现一些技术问题,我们正在使用 stargate api 将数据读取和写入 DSE Cassandra。我不得不说,我对 cassandra 甚至 NoSql 世界都是全新的。

我有几个字段,status(text)、status_code(text) 和 attemp_count(int)。现在我需要从 Cassandra 读取具有以下条件的数据。

条件:

status!='PROCESSED' and status_code!=400 and attemp_count<8

下面是我的桌子设计的样子。

下面是我遇到的错误。

列“status_code”有索引,但不支持查询中指定的运算符。如果您想在性能不可预测的情况下执行此查询,请使用 ALLOW FILTERING

{
    "description": **"Bad request: org.apache.cassandra.stargate.exceptions.InvalidRequestException:** Column 'status_code' has an index but does not support the operators specified in the query. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING",
    "code": 400
}

我用来做一个简单测试的查询:

{{url}}/v2/keyspaces/dco/mc_inbound_log?where={"status_code":{"$gt":"201"}}

【问题讨论】:

  • 这看起来更像是一个数据建模问题,而不是星际之门特定的问题。由于不支持对二级索引的范围查询,因此使用 CQL 会出现相同的错误。

标签: cassandra cql datastax-enterprise stargate-oss datastax-astra


【解决方案1】:

您可以尝试使用 status!='PROCESSED' and status_code!='400' and attemp_count

由于 status_code 是一个字符串,因此您需要引号。

【讨论】:

  • 感谢您的回答,但我一直在寻找与星际之门 api 的 where 子句相同的条件如何编写,就像我上面提到的那样。
  • 您可以尝试以下方法,但我不确定它是否会起作用,因为它看起来既没有为 status 也没有为 attempt_count 编制索引 {"status_code":{"$ne":"400"},"status":{"$ne": "PROCESSED"},"attempt_count":{"$lt": 8}}
【解决方案2】:

dwettlaufer 说这是一个数据建模问题确实是正确的。底层 CQL 查询无效,因此 Stargate.io 将无法运行它。

您正在过滤 (1) 不属于主键的列,以及 (2) 未编入索引的列。这就是为什么需要 (3) ALLOW FILTERING 的原因。负过滤器 (!=) 也很昂贵,因为它们需要全表扫描。

您有一个分析用例,因此请考虑使用 Spark 或 Solr。干杯!

【讨论】:

  • 感谢您的回复。以防万一,如果我现在需要在星际之门 api 上使用 ALLOW FILTERING,如何在下面的 url 上执行它。?? {{url}}/v2/keyspaces/dco/mc_inbound_log?where={"status_code":{"$gt":"201"}}。感谢任何帮助。
  • REST API 目前不支持ALLOW FILTERING
  • 我想回应@dwettlaufer 的回复。这是为了你的工作吗?如果您通过 Astra 网站上的实时聊天与我们联系,我们很乐意与您合作,看看我们能否提出解决方案。干杯!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-06-20
  • 1970-01-01
  • 1970-01-01
  • 2018-02-01
  • 2016-07-22
  • 2022-01-22
  • 1970-01-01
相关资源
最近更新 更多