title: Range query - Data modeling for time series in CQL Cassandra
body: <p>I have a table like this:</p>
  
  <blockquote>
    <p>CREATE TABLE test (   partitionkey text,   rowkey text, date
    timestamp,  policyid text,  policyname text, primary key
    (partitionkey, rowkey));</p>
  </blockquote>
  
  <p>with some data:</p>
  
  <blockquote>
    <p>partitionkey |    rowkey |    policyid |    policyname |  date</p>
  
  <pre><code>     p1 |   r1 |    pl1 |  plicy1 | 2007-01-02 00:00:00+0000
       p1 |   r2 |    pl2 |  plicy2 | 2007-01-03 00:00:00+0000
       p2 |   r3 |    pl3 |  plicy3 | 2008-01-03 00:00:00+0000
  </code></pre>
  </blockquote>
  
  <p>I want to be able to find:</p>
  
  <pre><code>1/ data from a particular partition key
  2/ data from a particular partition key &amp; rowkey
  3/ Range query on date given a partitionkey
  </code></pre>
  
  <p>1/ and 2/ are trivial:</p>
  
  <blockquote>
    <p>select * from test where partitionkey='p1';</p>
    
    <p>partitionkey | rowkey | policyid | policyname | range</p>
  
  <pre><code>    p1 |     r1 |      pl1 |     plicy1 | 2007-01-02 00:00:00+0000
      p1 |     r2 |      pl2 |     plicy2 | 2007-01-03 00:00:00+0000
  </code></pre>
  </blockquote>
  
  <p>but what about 3/? 
  Even with an index it doesnt work:</p>
  
  <blockquote>
    <p>create index i1 on test (date); </p>
    
    <p>select * from test where partitionkey='p1' and date =
    '2007-01-02';</p>
    
    <p>partitionkey | rowkey | policyid | policyname | date</p>
  
  <pre><code>  p1 |  r1 |   pl1   plicy1 | 2007-01-02 00:00:00+0000
  </code></pre>
    
    <p>but</p>
    
    <p>select * from test where partitionkey='p1' and
    date > '2007-01-02'; </p>
    
    <p>Bad Request: No indexed columns present in
    by-columns clause with Equal operator</p>
  </blockquote>
  
  <p>Any idea?
  thanks,
  Matt</p>