Cassandra中的双范围查询

Cassandra中的双范围查询,cassandra,cql,geohashing,Cassandra,Cql,Geohashing,我想执行双范围查询,以获取一个点附近的纬度和经度点 在卡桑德拉,这似乎是可能的,我只是尝试了一下 create column family users with comparator=UTF8Type AND key_validation_class=UTF8Type and column_metadata=[{column_name: full_name, validation_class: UTF8Type}, {column_name: type, validation_class

我想执行双范围查询,以获取一个点附近的纬度和经度点

在卡桑德拉,这似乎是可能的,我只是尝试了一下

create column family users
 with comparator=UTF8Type
 AND key_validation_class=UTF8Type
 and column_metadata=[{column_name: full_name, validation_class: UTF8Type},
 {column_name: type, validation_class: UTF8Type, index_type: KEYS},
 {column_name: lat, validation_class: LongType, index_type: KEYS},
 {column_name: lon, validation_class:  LongType, index_type: KEYS}];

SET users['a']['type']='test';                                             
SET users['b']['type']='test';
SET users['c']['type']='test';
SET users['a']['lat']='12';                                                
SET users['b']['lat']='9'; 
SET users['c']['lat']='12';
SET users['b']['lon']='1'; 
SET users['a']['lon']='4';
SET users['c']['lon']='2';
get users where type = 'test' and lon < '6' and lon > '3' and lat > '10' and lat < '13';
有可能绕过它吗

2) 按lat或lon对所有数据进行自然排序,然后查询另一个数据可能会很有趣

因此,只需在x和y之间对lat执行切片查询,然后执行查询

get users where type = 'test' and lon < '6' and lon > '3';
在type='test'和lon<'6'和lon>'3'中获取用户;
要不是按行名称而是按另一个字段(例如:字符串lat+lon和UTF8比较器)对CF进行排序,如何做到这一点


谢谢

您的解决方案可能适用于较小的数据集。一旦它增长,您需要一些空间索引来执行快速查找。Cassandra目前不支持空间索引。我建议您查看GeoCell/GeoHash

为每个点坐标创建哈希,然后可以对字符串执行范围查询。在这种情况下,Cassandra范围查询将是一个不错的选择

GeoHash是一种分层空间数据结构,它将空间细分为网格形状的桶

链接:

  • 维基百科:
  • Java实现

是的,就像弗拉达曼所说的,因为卡桑德拉地球电池是(唯一?)澄清可能是一个重要的初始误解的好方法:这些都不是CQL。您正在使用cassandra cli工具的特殊语法。
get users where type = 'test' and lon < '6' and lon > '3';