Details
-
Bug
-
Status: Resolved
-
Low
-
Resolution: Not A Bug
-
None
-
None
-
Low
Description
I use Cassandra 3.7 and have a text column with SASI index. Let's assume that I want to find column values that contain '%' character somewhere in the middle. The problem is that '%' is a command char for LIKE clauses. How to escape '%' char in a query like LIKE '%%%'?
Here is a test script:
DROP keyspace if exists kmv; CREATE keyspace if not exists kmv WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor':'1'} ; USE kmv; CREATE TABLE if not exists kmv (id int, c1 text, c2 text, PRIMARY KEY(id, c1)); CREATE CUSTOM INDEX ON kmv.kmv ( c2 ) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'analyzed' : 'true', 'analyzer_class' : 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive' : 'false', 'mode' : 'CONTAINS' }; INSERT into kmv (id, c1, c2) values (1, 'f22', 'qwe%asd'); SELECT c2 from kmv.kmv where c2 like '%$$%$$%';
The select query returns nothing.