Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cassandra包含查询错误_Cassandra_Cql_Cassandra 2.0 - Fatal编程技术网

Cassandra包含查询错误

Cassandra包含查询错误,cassandra,cql,cassandra-2.0,Cassandra,Cql,Cassandra 2.0,我是Cassandra的新手,正在尝试找出如何使用Cassandra获得一个简单的包含查询 我的桌子看起来像这样 CREATE TABLE events ( timekey text, id timeuuid, event_types list<text>, PRIMARY KEY ((timekey), id) ) 对这个错误有什么想法吗 也可以在一个查询中查询多个事件类型。我看不出有什么办法可以这样做。在常规sql中与此等价的内容 关系SQL示例: select

我是Cassandra的新手,正在尝试找出如何使用Cassandra获得一个简单的包含查询

我的桌子看起来像这样

CREATE TABLE events (
  timekey text,
  id timeuuid,
  event_types list<text>,
  PRIMARY KEY ((timekey), id)
)
对这个错误有什么想法吗

也可以在一个查询中查询多个事件类型。我看不出有什么办法可以这样做。在常规sql中与此等价的内容

关系SQL示例:

select count(1) from events where event_types in ('foo', 'bar')

有几件事。首先,当我创建您的模式并插入一行时,我会收到与您不同的错误消息:

aploetz@cqlsh:stackoverflow2> CREATE TABLE events (
              ...   timekey text,
              ...   id timeuuid,
              ...   event_types list<text>,
              ...   PRIMARY KEY ((timekey), id)
              ... );
aploetz@cqlsh:stackoverflow2> INSERT INTO events (timekey, id, event_types) 
    VALUES ('1', now(),['foo','bar']);
aploetz@cqlsh:stackoverflow2> select count(1) from events where event_types contains 'foo';
InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on the restricted
    columns support the provided operators: "
尽管这可能有效,但大型表或大型集群中的二级索引的性能并不好。我希望集合上的二级索引的性能会更差,所以这只是一个警告

还可以在一个查询中查询多个事件类型吗


有很多方法可以实现这一点,但我建议不要使用上述性能问题。如果您感兴趣,我在这里回答了一个类似的问题:

谢谢@Bryce。很高兴知道这是由于版本。似乎我们最近将其从2.1降级到了2.0,因为当时它是最稳定的版本。我想是时候升级了。另外,关于性能问题,我的实际查询还包括where子句中的主/分区键。因此可能会稍微好一点,我会像这样查询它“从事件中选择*,其中事件类型包含'foo'和id>04e2c71a-2ae9-11e5-a468-6318a3eb3a8a和timekey in('201506171850')”@Saddy包含分区键是个好主意。这肯定会有帮助。
aploetz@cqlsh:stackoverflow2> CREATE TABLE events (
              ...   timekey text,
              ...   id timeuuid,
              ...   event_types list<text>,
              ...   PRIMARY KEY ((timekey), id)
              ... );
aploetz@cqlsh:stackoverflow2> INSERT INTO events (timekey, id, event_types) 
    VALUES ('1', now(),['foo','bar']);
aploetz@cqlsh:stackoverflow2> select count(1) from events where event_types contains 'foo';
InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on the restricted
    columns support the provided operators: "
aploetz@cqlsh:stackoverflow2> CREATE INDEX eventTypeIdx ON events(event_types);
aploetz@cqlsh:stackoverflow2> select count(1) from events where event_types contains 'foo';

 count
-------
     1

(1 rows)