Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query for CONTAINS on an index in Cassandra 2.1.5

There is a table book which has the following definition. Book name will be stored in column name - attributes will be a map which will hold attributes such as authorname, yearofpublishing, etc.

CREATE TABLE book (
    bookid uuid PRIMARY KEY,
    createdat timestamp,
    createdon timestamp,
    description text,
    attributes map<text, text>,
    name text
) CREATE INDEX bookbyname ON project (name);

Question - A query should be developed to run from a generic search on the UI which will supply a string. That String should query [CONTAINS] on both the attributes column and name.

For Attributes, since it was a MAP, it supports CONTAINS keyword. However, how to do a CONTAINS query on index? In this case, bookbyname (name) field.

like image 606
Karthik Shivkumar Avatar asked Dec 01 '25 18:12

Karthik Shivkumar


1 Answers

Cassandra does not support matching partial strings using the CONTAINS or LIKE operator. You should look into solutions such as Stargate or DSE that provide search functionality on top of Cassandra.

like image 163
Stefan Podkowinski Avatar answered Dec 05 '25 04:12

Stefan Podkowinski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!