卡桑德拉API相当于“SELECT ... FROM ... WHERE ID IN( '...', '...', '...');”

StackOverflow https://stackoverflow.com/questions/2445878

  •  20-09-2019
  •  | 
  •  

假定以下数据集:

id       age  city      phone
==       ===  ====      =====
alfred   30   london    3281283
jeff     43   sydney    2342734
joe      29   tokyo     1283881
kelly    54   new york  2394929
molly    20   london    1823881
rob      39   sydney    4928381

要得到以下结果集..

id       age  phone
==       ===  =====
alfred   30   3281283
joe      29   1283881
molly    20   1823881

..使用SQL一个会发出..

SELECT id, age, phone FROM dataset WHERE id IN ('alfred', 'joe', 'molly');

什么是对应卡桑德拉API调用,将产生相同的结果在一个命令设置?

有帮助吗?

解决方案

CQL(Cassandra的SQL的查询语言)现在支持这样的:

SELECT ... WHERE keyalias IN ('key1', 'key2', 'key3', ...);

http://cassandra.apache.org/doc/cql/CQL。 HTML#Filteringrows

其他提示

你会做一个multiget_slice W /阿尔弗雷德,乔,莫莉和ID,年龄SlicePredicate COLUMN_NAMES的钥匙,手机

如下所述甲卡桑德拉等效可以建模:

Users = { //this is a ColumnFamily
  "alfred": { //this is the key to this Row inside the CF
     "age":"30",
     "city":"london",
     "phone":"3281283"
  }, // end row
  // more rows...
}

其中“阿尔弗雷德”是您的(行)密钥和行有三列;年龄,城市和电话。 (已失时间戳字段(为简单起见)为三列)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top