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

问题描述

我试图通过表中的辅助索引或列键来删除。我不关心性能,因为这将是一个不寻常的查询。不知道是否可能?例如:

  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;

  id |名称| 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 |名称| 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在'allow'处缺少EOF
cqlsh> delete from dat.user_range where name ='1000 - 1999';
错误的请求:缺少必需的PRIMARY KEY部分ID

即使我创建索引: / p>

  cqlsh>在dat.user_range(start)上创建索引; 
cqlsh>从dat.user_range中删除,其中start = 1000;
错误的请求:非PRIMARY KEY在where子句中找到开始

不,不支持使用辅助索引进行删除:


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;

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

I can:

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…

But I can’t delete:

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

Even if I create an index:

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?

解决方案

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

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

11-03 11:05