我试图在cassandra CQL中执行条件查询但它给我的错误就像
cqlsh:events> select * from standardevents where name=ActivityPg_view;我正在执行上面的查询,它给我下面的错误
错误请求:第1:55行输入';'没有可行的选择 也许你打算使用CQL 2? 启动cqlsh时尝试使用-2选项。
cqlsh:events> select * from standardevents其中name ='ActivityPg_view';
我正在执行上面的查询,它给我下面的错误
错误请求:使用Equal运算符的by-columns子句中不存在索引列
当我尝试使用CQL 2执行时
cqlsh:events> select * from standardevents where name=ActivityPg_view;它给我低于误差,
错误请求:by-columns子句中没有带有“equals”操作符的索引列
cqlsh:events> select * from standardevents其中name ='ActivityPg_view';
它给我低于误差,
错误请求:带有“等于”操作符的by-columns子句中没有索引列可能您打算使用CQL 3? 启动cqlsh时尝试使用-3选项。
那么有人可以提出问题以及如何解决这个问题并执行条件查询?
cqlsh> DESCRIBE COLUMNFAMILY events.standardevents; CREATE TABLE standardevents ( uuid timeuuid PRIMARY KEY, data text, name text, time text, tracker text, type text, userid text ) WITH bloom_filter_fp_chance=0.010000 AND caching='KEYS_ONLY' AND comment='' AND dclocal_read_repair_chance=0.000000 AND gc_grace_seconds=864000 AND read_repair_chance=0.100000 AND replicate_on_write='true' AND populate_io_cache_on_flush='false' AND compaction={'class': 'SizeTieredCompactionStrategy'} AND compression={'sstable_compression': 'SnappyCompressor'};i am trying to execute conditional query in cassandra CQL but it is giving me error like
cqlsh:events> select * from standardevents where name=ActivityPg_view;i am executing above query, it is giving me below error
Bad Request: line 1:55 no viable alternative at input ';' Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.
cqlsh:events> select * from standardevents where name='ActivityPg_view';
i am executing above query, it is giving me below error
Bad Request: No indexed columns present in by-columns clause with Equal operator
when i am trying to execute using CQL 2
cqlsh:events> select * from standardevents where name=ActivityPg_view;it is giving me below error,
Bad Request: No indexed columns present in by-columns clause with "equals" opera tor
cqlsh:events> select * from standardevents where name='ActivityPg_view';
it is giving me below error,
Bad Request: No indexed columns present in by-columns clause with "equals" opera tor Perhaps you meant to use CQL 3? Try using the -3 option when starting cqlsh.
so can somebody suggest the problem and how to solve this thing and execute the conditional query?
cqlsh> DESCRIBE COLUMNFAMILY events.standardevents; CREATE TABLE standardevents ( uuid timeuuid PRIMARY KEY, data text, name text, time text, tracker text, type text, userid text ) WITH bloom_filter_fp_chance=0.010000 AND caching='KEYS_ONLY' AND comment='' AND dclocal_read_repair_chance=0.000000 AND gc_grace_seconds=864000 AND read_repair_chance=0.100000 AND replicate_on_write='true' AND populate_io_cache_on_flush='false' AND compaction={'class': 'SizeTieredCompactionStrategy'} AND compression={'sstable_compression': 'SnappyCompressor'};最满意答案
您的表(CF)没有名为courseid的字段(因此错误“where子句中的未定义名称courseid”)。 您无法查询不存在的内容。
你期待那里的那个领域吗? (如果有帮助,那个表的PK被称为'uuid')你在查询正确的表格吗? 没有其他建议。
编辑:更新后
您的CQL3尝试缺少名称周围的引号,但除此之外......在Cassandra中,您无法通过非键列随机查询。 Cassandra是一个分区行存储,它并不是真正用于以您尝试的方式进行查询。
您可以添加辅助索引来解决此问题,但您应该意识到它与传统SQL不同。 拥有第二个索引需要将群集中的所有节点都命中到查询中。 如果您的数据具有高基数,这也是不理想的。
在Cassandra中,一般的前提是存储很便宜,您应该根据查询而不是数据来建立模型。 一切都不正常。 例如,如果您需要按名称提取事件,那么您应该创建一个按名称键入的表,并包含您需要的所有事件数据。 这样读取它们(基本上)和O(1)操作。
Your table (CF) has no field called courseid (hence the error "Undefined name courseid in where clause"). You can't query on something that doesn't exist.
Were you expecting that field there? (Your PK for that table is called 'uuid' if that helps) Are you querying the right table? Not much else to suggest.
Edit: After update
Your CQL3 attempt is missing the quotes around the name, but that aside ... In Cassandra you can't randomly query by non key columns. Cassandra is a partitioned row store, and it is not really designed to do query's in the manner you are trying.
You could add a secondary index to fix this, but you should be aware it not like in traditional SQL. Having a 2ndary index will need to hit all nodes in a cluster do to the query. It's also not ideal if your data has high cardinality.
In Cassandra the general premise is that storage is cheap, and you should base your model on your query rather than your data. Denormalise everything. For example, if you need to pull events by name, then you should make a table that is key'd by name, and includes all the event data you need. That way reading them is (essentially) and O(1) operation.
更多推荐
发布评论