When I used MySQL I was able to query the database with a statement like SELECT * FROM table WHERE col LIKE "%attribute%";
Is there a way I can do that in Cassandra?
Cassandra CQL doesn't have a LIKE
operator. It has limited filtering capabilities so you are restricted to equals, range queries on some numeric fields, and the IN operator which is similar to equals.
The most common approach to doing searches of Cassandra data seems to be pairing Cassandra with Apache Solr. Or you can pair it with Apache Spark which has more filtering capabilities than CQL.
If your col is a collection of data like set, list, map. You could use CONTAINS, to perform search.
Sample:
SELECT id, description FROM products WHERE features CONTAINS '32-inch';
For map data type,
SELECT id, description FROM products WHERE features CONTAINS KEY 'refresh-rate';
References: http://www.datastax.com/dev/blog/cql-in-2-1
CQL LIKE statements now available are in Scylla Open Source 3.2 RC1, the release candidate for Scylla, a CQL-compatible database. We'd love feedback before release. Here's the details:
The new CQL LIKE keyword allows matching any column to a search pattern, using % as a wildcard. Note that LIKE only works with ALLOW FILTERING.
LIKE Syntax support:
'_' matches any single character
'%' matches any substring (including an empty string)
'\' escapes the next pattern character, so it matches verbatim
any other pattern character matches itself
an empty pattern matches empty text fields
For example:
INSERT INTO t (id, name) VALUES (17, ‘Mircevski’)
SELECT * FROM t where name LIKE 'Mirc%' allow filtering
Source: [RELEASE] Scylla 3.2 RC1 2