You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Alex Petrov (JIRA)" <ji...@apache.org> on 2016/09/13 12:50:20 UTC
[jira] [Resolved] (CASSANDRA-12621) How to query '%' character
using LIKE operator in Cassandra 3.7?
[ https://issues.apache.org/jira/browse/CASSANDRA-12621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alex Petrov resolved CASSANDRA-12621.
-------------------------------------
Resolution: Not A Bug
For usage-related questions you can use [mailing list|http://mail-archives.apache.org/mod_mbox/cassandra-user/].
Since wildcards can be in the beginning and the end of pattern, you can use the following query:
{code}
cqlsh:kmv> SELECT c2 from kmv.kmv where c2 like '%%%';
c2
---------
qwe%asd
{code}
Which would turn it into the {{CONTAINS}} query that'd search for {{%}}.
> How to query '%' character using LIKE operator in Cassandra 3.7?
> ----------------------------------------------------------------
>
> Key: CASSANDRA-12621
> URL: https://issues.apache.org/jira/browse/CASSANDRA-12621
> Project: Cassandra
> Issue Type: Bug
> Reporter: Mikhail Krupitskiy
> Priority: Critical
> Labels: sasi
>
> 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:
> {code}
> 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 '%$$%$$%';
> {code}
> The select query returns nothing.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)