title: SASI Indexes in Cassandra seem to have some bugs
body: <p>I just started working with the SASI index on Cassandra 3.7.0 and I encountered a problem which as I suspected was a bug. I had hardly tracked down the situation in which the bug showed up, here is what I found:</p>
  
  <p>When querying with a SASI index, <strong>it may incorrectly return 0 rows</strong>, and changing a little conditions, it works again, like the following CQL code:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS roles (
      name text,
      a int,
      b int,
      PRIMARY KEY ((name, a), b)
  ) WITH CLUSTERING ORDER BY (b DESC);
  
  insert into roles (name,a,b) values ('Joe',1,1);
  insert into roles (name,a,b) values ('Joe',2,2);
  insert into roles (name,a,b) values ('Joe',3,3);
  insert into roles (name,a,b) values ('Joe',4,4);
  
  CREATE TABLE IF NOT EXISTS roles2 (
      name text,
      a int,
      b int,
      PRIMARY KEY ((name, a), b)
  ) WITH CLUSTERING ORDER BY (b ASC);
  
  insert into roles2 (name,a,b) values ('Joe',1,1);
  insert into roles2 (name,a,b) values ('Joe',2,2);
  insert into roles2 (name,a,b) values ('Joe',3,3);
  insert into roles2 (name,a,b) values ('Joe',4,4);
  
  CREATE CUSTOM INDEX ON roles (b) USING 'org.apache.cassandra.index.sasi.SASIIndex' 
  WITH OPTIONS = { 'mode': 'SPARSE' };
  CREATE CUSTOM INDEX ON roles2 (b) USING 'org.apache.cassandra.index.sasi.SASIIndex' 
  WITH OPTIONS = { 'mode': 'SPARSE' };
  </code></pre>
  
  <p>Noticing that I only change table <strong><em>roles2</em></strong> from table <strong><em>roles</em></strong>'s '<strong><em>CLUSTERING ORDER BY (b DESC)</em></strong>' into '<strong><em>CLUSTERING ORDER BY (b ASC)</em></strong>'.</p>
  
  <p>When querying with statement <code>select * from roles2 where b&lt;3;</code>, the rusult is two rows:</p>
  
  <pre><code> name | a | b
  ------+---+---
    Joe | 1 | 1
    Joe | 2 | 2
  
  (2 rows)
  </code></pre>
  
  <p>However, if querying with <code>select * from roles where b&lt;3;</code>, it returned no rows at all:</p>
  
  <pre><code> name | a | b
  ------+---+---
  
  (0 rows)
  </code></pre>
  
  <p>This is not the only situation where the bug would show up, one time I created a SASI index with specific name like 'end_idx' on column 'end', the bug showed up, when I didn't specify the index name, it gone.</p>
  
  <p>Please help me confirm this bug, or tell me if I'd used the SASI index the wrong way.</p>