我想执行一个双范围查询以获取一个点附近的纬度和经度点,
在 Cassandra 现在似乎有可能,我刚刚尝试过
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';
RowKey: a => (column=lat, value=12, timestamp=1336339056413000) => (column=lon, value=4, timestamp=1336339088170000) => (column=type, value=test, timestamp=1336339033765000)
返回 1 行。
但是我很担心添加数千点时的性能,如果这 3 列被索引。
1)我必须使用索引的“类型”列,因为没有它,查询会失败
No indexed columns present in index clause with operator EQ
有可能绕过它吗?
2)自然地按纬度或经度对所有数据进行排序可能会很有趣,然后只查询另一个,
所以只需对 x 和 y 之间的 lat 做一个 SliceQuery,然后是一个查询
get users where type = 'test' and lon < '6' and lon > '3';
要不是按行名而是按另一个字段(例如:字符串 lat+lon 和 UTF8 比较器)对 CF 进行排序,该怎么做?
谢谢