Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-13543

Cassandra SASI index gives unexpected number of results

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Normal
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: Feature/SASI
    • Labels:
      None
    • Severity:
      Normal

      Description

      I've faced the issue with LIKE query to the column indexed by SASI index. Cassandra can return different number of rows when the data stays immutable.

      CREATE TABLE idx_test
      (
      	id int,
      	str text,
      	i int,
      	PRIMARY KEY (id)
      );
      
      
      CREATE CUSTOM INDEX idx_test_idx ON idx_test (str)
      USING 'org.apache.cassandra.index.sasi.SASIIndex'
      WITH OPTIONS = { 
      	'mode': 'CONTAINS',
      	'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer',
      	'tokenization_enable_stemming': 'true',
      	'tokenization_normalize_lowercase': 'true'
      };
      
      INSERT INTO idx_test (id, str, i) VALUES (1, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (2, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (3, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (4, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (5, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (6, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (7, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (8, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (9, 'a b c d', 10);
      INSERT INTO idx_test (id, str, i) VALUES (10, 'a b c d', 10);
      

      Query:

      SELECT * FROM idx_test WHERE str LIKE 'b' 
      AND i = 10
      ALLOW FILTERING;
      

      This query mostly returns 0 rows, but sometimes 1 row appears in result row set as:

      id |  i  |  str
      10 |  10 |  a b c d
      

        Attachments

          Activity

            People

            • Assignee:
              jrwest Jordan West
              Reporter:
              sune357 Alexander Nabatchikov
              Authors:
              Jordan West
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: