Skip to content

Instantly share code, notes, and snippets.

@doanduyhai

doanduyhai/sasi_bug.md

Last active Feb 5, 2016
Embed
What would you like to do?
SASI Bug
CREATE KEYSPACE music WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;

CREATE FUNCTION music.show_me_space(val text)
    RETURNS NULL ON NULL INPUT
    RETURNS text
    LANGUAGE java
    AS $$ return "_" + val + "_"; $$;
    
CREATE TABLE music.albums (
    title text PRIMARY KEY,
    artist text,
    country text,
    quality text,
    status text,
    year int
);

INSERT INTO music.albums(artist,title) VALUES('Object','The Reflecting Skin');
INSERT INTO music.albums(artist,title) VALUES('Hayden','Mild and Hazy');
INSERT INTO music.albums(artist,title) VALUES('Самое Большое Простое Число','СБПЧ Оркестр');

CREATE custom INDEX on music.albums(artist) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive': 'false'};

SELECT * FROM music.albums;


 title               | artist                      | country | quality | status | year
---------------------+-----------------------------+---------+---------+--------+------
 The Reflecting Skin |                      Object |    null |    null |   null | null
       Mild and Hazy |                      Hayden |    null |    null |   null | null
        СБПЧ Оркестр | Самое Большое Простое Число |    null |    null |   null | null
        
(3 rows)

SELECT * FROM albums WHERE artist='Самое Большое Простое Число';

 title        | artist                      | country | quality | status | year
--------------+-----------------------------+---------+---------+--------+------
 СБПЧ Оркестр | Самое Большое Простое Число |    null |    null |   null | null

(1 rows)

SELECT * FROM albums WHERE artist='Hayden';

 title         | artist | country | quality | status | year
---------------+--------+---------+---------+--------+------
 Mild and Hazy | Hayden |    null |    null |   null | null

(1 rows)

SELECT * FROM albums WHERE artist='Object';

 title | artist | country | quality | status | year
-------+--------+---------+---------+--------+------

(0 rows)

SELECT * FROM albums WHERE artist like 'Ob%';

 title | artist | country | quality | status | year
-------+--------+---------+---------+--------+------

(0 rows)

SELECT artist,show_me_space(artist) FROM albums;

 artist                      | music.show_me_space(artist)
-----------------------------+-------------------------------
                      Object |                      _Object_
                      Hayden |                      _Hayden_
 Самое Большое Простое Число | _Самое Большое Простое Число_
 
 (3 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment