Cassandra 二级索引问题 - 返回零行

标签 cassandra

我有一个问题,因为二级索引在 cassandra 中返回零行:

我正在遵循入门文档:

http://www.datastax.com/documentation/getting_started/doc/getting_started/gettingStartedCQL.html

基于此,我有以下 cassandra 脚本

/* hello.cql */
drop keyspace test;
CREATE KEYSPACE test WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use test;
CREATE TABLE users (  user_id int PRIMARY KEY,   fname text,   lname text);
DESCRIBE TABLES;
INSERT INTO users (user_id,  fname, lname) 
  VALUES (1745, 'john', 'smith');
INSERT INTO users (user_id,  fname, lname) 
  VALUES (1744, 'john', 'doe');
INSERT INTO users (user_id,  fname, lname) 
  VALUES (1746, 'john', 'smith');
SELECT * FROM users;
CREATE INDEX ON users (lname);

/* These queries both return 0 rows ??? */
SELECT * FROM users WHERE lname = 'smith';
SELECT * FROM users WHERE lname = 'doe';

但是...

cqlsh < hello.cql 

users


 user_id | fname | lname
---------+-------+-------
    1745 |  john | smith
    1744 |  john |   doe
    1746 |  john | smith

(3 rows)

(0 rows)

(0 rows)

这应该很简单——我错过了什么吗?

最佳答案

对于返回结果的 2 个 SELECT 查询意味着 CREATE INDEX 将同步执行并且它将 所有现有数据都被索引后返回。

如果您更改脚本中的顺序以在插入任何数据之前定义索引,我希望 2 个选择返回结果。

关于Cassandra 二级索引问题 - 返回零行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25965124/

相关文章:

cassandra - CQL 在输入 '(' 错误处没有可行的选择

hadoop - 如何在 Pig Latin 中生成大量数据的不同平均值?

php - php (phpcassa) 中的最低可能 timeuuid

scala - Cassandra spark 连接器编写嵌套的可选案例类

indexing - Spark SQL 是否使用 Cassandra 二级索引?

java - 是否有一些 Java api 将复杂的 JSON 存储到 Cassandra?

java - DataStax Java 驱动程序 4.0 : is object mapping going to be supported?

Cassandra 在特定列之后添加列

cassandra - 过滤条件不适用于 ScyllaDB 中的计数器列,而它在 Cassandra 3.0 中起作用

cassandra - 检查 Astyanax Keyspace 是否为空或不存在