Cassandra:无法使用非主键更新行(即使我创建了索引。)

时间:2013-01-04 14:25:40

标签: indexing cassandra cql

目前收到此错误消息:

错误请求:'UserGameAnswers'的WHERE子句中出现的预期键'KEY'

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? :(

1 个答案:

答案 0 :(得分:1)

是 - 您需要确定密钥并根据该密钥编写更新。