相关疑难解决方法(0)

cassandra获得时间范围内的所有记录

我必须使用以(user_id,timestamp)为键的列族.在我的查询中,我想获取给定时间范围内的所有记录,与user_id无关.这是确切的表模式:

CREATE TABLE userlog (
  user_id text,
  ts timestamp,
  action text,
  app_type text,
  channel_name text,
  channel_session_id text,
  pid text,
  region_id text,
  PRIMARY KEY (user_id, ts)
)
Run Code Online (Sandbox Code Playgroud)

我试着跑

SELECT * FROM userlog  WHERE ts >= '2013-01-01 00:00:00+0200' AND  ts <= '2013-08-13 23:59:00+0200' ALLOW FILTERING;
Run Code Online (Sandbox Code Playgroud)

这在我的本地cassandra安装中工作正常,包含一个小数据集,但失败了

Request did not complete within rpc_timeout.
Run Code Online (Sandbox Code Playgroud)

在包含所有数据的生产系统上.

是否有一个,最好是cql,查询与给定的列系列顺利运行或de我们必须更改设计?

cql cassandra

27
推荐指数
2
解决办法
6万
查看次数

cassandra中二级索引的范围查询

我正在使用cassandra 2.1.10.所以首先我要清楚我知道二级索引是cassandra中的反模式.但是出于测试目的,我试图遵循:

CREATE TABLE test_topology1.tt (
    a text PRIMARY KEY,
    b timestamp
) WITH bloom_filter_fp_chance = 0.01
    AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
    AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99.0PERCENTILE';
CREATE INDEX idx_tt ON test_topology1.tt (b);
Run Code Online (Sandbox Code Playgroud)

当我运行以下查询时,它给了我错误.

cqlsh:test_topology1> Select * from tt …
Run Code Online (Sandbox Code Playgroud)

cassandra cql3 cassandra-2.0

5
推荐指数
1
解决办法
4364
查看次数

尽管存在相等运算符和二级索引,但Cassandra CQL范围查询被拒绝

从下面的表格图中,我试图选择低于5的所有pH读数.

我遵循了这三条建议:

  1. 使用ALLOW FILTERING
  2. 包括相等比较
  3. 在reading_value列上创建二级索引.

这是我的查询:

select * from todmorden_numeric where sensor_name = 'pHradio' and reading_value < 5  allow filtering;
Run Code Online (Sandbox Code Playgroud)

哪条信息被拒绝:

Bad Request: No indexed columns present in by-columns clause with Equal operator
Run Code Online (Sandbox Code Playgroud)

我尝试将一个辅助索引添加到sensor_name列,并被告知它已经是密钥的一部分,因此已经编入索引.

我在表中使用了一段时间之后创建了索引 - 这可能是问题吗?我运行"nodetool refresh"希望它能使索引可用,但这不起作用.这是输出describe table todmorden_numeric:

CREATE TABLE todmorden_numeric (
  sensor_name text,
  reading_time timestamp,
  reading_value float,
  PRIMARY KEY ((sensor_name), reading_time)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='Data that suits being stored as floats' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  index_interval=128 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' …
Run Code Online (Sandbox Code Playgroud)

cql cassandra range-query secondary-indexes

4
推荐指数
1
解决办法
2255
查看次数