地图功能
from cassandra.cluster import Cluster
from cassandra.policies import DCAwareRoundRobinPolicy
from cassandra.auth import PlainTextAuthProvider
def cassandra_conn():
auth_provider = PlainTextAuthProvider(username='cassandra', password='password')
cluster = Cluster(['127.0.0.1'], load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='US-WEST'), port=9042, auth_provider=auth_provider)
session = cluster.connect()
return session, cluster
产地:
function(doc, meta) {
if (doc.login_timestamp) {
emit(dateToArray(doc.login_timestamp), doc.username);
}
}
如何获得2013年的记录? 我试过了
[2011,10,10,10,10,09] “scalabl3”
[2012,12,24,17,03,59] “scalabl3”
[2013,01,01,08,22,23] “scalabl3”
[2013,01,25,10,38,01] “tgrall”
[2013,01,25,11,02,32] “jzablocki”
[2013,02,01,11,02,32] “scalabl3”
这不起作用,因为根据定义,结果必须大于等于起始键且小于结束键
这样做的正确方法是什么?
答案 0 :(得分:1)
由于您有一个数组,您可以为start和end指定数组。所以应该采用以下两种方法之一:
startkey=[2013]&endkey=[2014]
或
startkey=[2013]&endkey=[2013,99]
在第二个示例中,您给出的值大于您希望在有效条目中看到的值。