Cassandra:在带有主键的where子句中为空结果

Cassandra: Empty results in where clause with primary key

我在 Cassandra 中有以下模型:

CREATE TABLE segment (
  organizationid varchar, 
  segmentid int,
  lengthmm int,
  optimal_speed int, 
  speed_limit int,
  wkt varchar,
  road_class int,
  PRIMARY KEY (organizationid, segmentid)
);

此处描述:

CREATE TABLE tkm_fcd_cassandra.segment (
    organizationid text,
    segmentid int,
    lengthmm int,
    optimal_speed int,
    road_class int,
    speed_limit int,
    wkt text,
    PRIMARY KEY (organizationid, segmentid)
) WITH CLUSTERING ORDER BY (segmentid ASC)
    AND 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', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    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 = '99PERCENTILE';

当我运行以下查询时:

select * from segment;

它给了我以下结果:

organizationid             | segmentid | lengthmm | optimal_speed | road_class | speed_limit | wkt
----------------------------+-----------+----------+---------------+------------+-------------+---------------------------------------------------------
 '57ecdd14766299a02213c463' |    122406 |    49239 |            20 |          5 |          90 |  'LINESTRING (32.813454 39.918419,32.813469 39.917976)'
 '57ecdd14766299a02213c463' |    122407 |    49239 |            20 |          5 |          90 |  'LINESTRING (32.813469 39.917976,32.813501 39.917533)'
 '57ecdd14766299a02213c463' |    122408 |    49239 |            20 |          5 |          90 |  'LINESTRING (32.813501 39.917533,32.813532 39.917091)'
 '57ecdd14766299a02213c463' |    122409 |    49239 |            20 |          5 |          90 |   'LINESTRING (32.813532 39.917091,32.813542 39.91665)'
 '57ecdd14766299a02213c463' |    122410 |    49239 |            20 |          5 |          90 |   'LINESTRING (32.813542 39.91665,32.813112 39.916359)'

但是当我运行下面的查询时:

select * from segment where organizationid = '57ecdd14766299a02213c463';

我得到以下结果:

 organizationid | segmentid | lengthmm | optimal_speed | road_class | speed_limit | wkt
----------------+-----------+----------+---------------+------------+-------------+-----

(0 rows)

这是我的节点工具状态:

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address        Load       Tokens       Owns (effective)  Host ID                               Rack
UN  192.168.1.101  5.16 MiB   256          100.0%            249c522d-ead0-4370-ac1b-4ad446d4948b  rack1

其他信息:

[cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]

我不明白为什么 Cassandra 在 运行 where 子句时给我空结果?

我看起来像你插入了你的 ID,并用引号括起来。尝试以下操作:

select * from segment where organizationid = '\'57ecdd14766299a02213c463\'';

通常输出不显示 ' 文本值。