【问题标题】:Cassandra: unable to update a row with a non-primary key (even though I created an index.)Cassandra:无法使用非主键更新行(即使我创建了索引。)
【发布时间】:2013-01-05 03:06:09
【问题描述】:

目前收到此错误消息:

错误请求:预期密钥“KEY”将出现在“UserGameAnswers”的 WHERE 子句中

cqlsh:godofsports> UPDATE UserGameAnswers SET 'status' = 'thing' WHERE 'event_question_id' = '7';
Bad Request: Expected key 'KEY' to be present in WHERE clause for 'UserGameAnswers'

鉴于我有一个针对此列键的索引(见下文)并且 this should be allowed 我做错了什么?

cqlsh:godofsports> DESCRIBE COLUMNFAMILY UserGameAnswers;

CREATE TABLE UserGameAnswers (
  KEY text PRIMARY KEY,
  event_question_id text
) WITH
  comment='' AND
  comparator=ascii AND
  read_repair_chance=0.100000 AND
  gc_grace_seconds=864000 AND
  default_validation=text AND
  min_compaction_threshold=4 AND
  max_compaction_threshold=32 AND
  replicate_on_write='true' AND
  compaction_strategy_class='SizeTieredCompactionStrategy' AND
  compression_parameters:sstable_compression='SnappyCompressor';

CREATE INDEX event_question_id_idx ON UserGameAnswers (event_question_id);

我需要先进行查询以获取实际的 KEY 吗? :(

【问题讨论】:

  • 我现在正在其他查询中获取所有键。看来您不能将 IN () 与二级索引一起使用...

标签: indexing cassandra cql


【解决方案1】:

是的 - 您需要确定密钥并针对该密钥编写更新。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    • 1970-01-01
    • 2013-12-06
    • 1970-01-01
    • 2021-07-06
    • 2021-10-10
    • 1970-01-01
    相关资源
    最近更新 更多