通过二级索引或允许过滤的 Cassandra 删除 [英] Cassandra Delete by Secondary Index or By Allowing Filtering

查看:31
本文介绍了通过二级索引或允许过滤的 Cassandra 删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按表中的二级索引或列键进行删除.我不关心性能,因为这将是一个不寻常的查询.不确定是否可能?例如:

I’m trying to delete by a secondary index or column key in a table. I'm not concerned with performance as this will be an unusual query. Not sure if it’s possible? E.g.:

CREATE TABLE user_range (
  id int,
  name text,
  end int,
  start int,
  PRIMARY KEY (id, name)
)

cqlsh> select * from dat.user_range where id=774516966;

cqlsh> select * from dat.user_range where id=774516966;

id        | name      | end | start
-----------+-----------+-----+-------
774516966 |   0 - 499 | 499 |     0
774516966 | 500 - 999 | 999 |   500

我可以:

cqlsh> select * from dat.user_range where name='1000 - 1999' allow filtering;

id          | name        | end  | start
-------------+-------------+------+-------
 -285617516 | 1000 - 1999 | 1999 |  1000
 -175835205 | 1000 - 1999 | 1999 |  1000
-1314399347 | 1000 - 1999 | 1999 |  1000
-1618174196 | 1000 - 1999 | 1999 |  1000
Blah blah…

但我无法删除:

cqlsh> delete from dat.user_range where name='1000 - 1999' allow filtering;
Bad Request: line 1:52 missing EOF at 'allow'
cqlsh> delete from dat.user_range where name='1000 - 1999';
Bad Request: Missing mandatory PRIMARY KEY part id

即使我创建了索引:

cqlsh> create index on dat.user_range (start);
cqlsh> delete from dat.user_range where start=1000;
Bad Request: Non PRIMARY KEY start found in where clause

不知道主键可以删除吗?

Is it possible to delete without first knowing the primary key?

推荐答案

否,不支持使用二级索引删除:CASSANDRA-5527

No, deleting by using a secondary index is not supported: CASSANDRA-5527

这篇关于通过二级索引或允许过滤的 Cassandra 删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆