2

I'm new to Cassandra and I need to do a text search through one or more VARCHAR type fileds using CQL and PHP. Usually with MySQL I used the LIKE operator but as I know in Cassandra is not possible, which is the alternative for do that in CQL? Note that I'm using Cassandra version 2.2.1 and the DataStax PHP-Driver.

Community
  • 1
  • 1
RyanJ
  • 131
  • 5
  • 16
  • 1
    possible duplicate of [Is there any query for Cassandra as same as SQL:LIKE Condition?](http://stackoverflow.com/questions/9905795/is-there-any-query-for-cassandra-as-same-as-sqllike-condition) – uri2x Sep 16 '15 at 17:21
  • It looks like duplicate but it is not - that question is about "Cassandra 0.8.x" and current is about "Cassandra 2.2.1" so author hope that LIKE s appear, I suppose. – Andriy Kuba Sep 23 '15 at 07:11
  • Sorry, I didn't see this question in search during the post creation but as I seen later it is referred to an old version of Cassandra and I didn't find a proper solution. – RyanJ Sep 25 '15 at 13:43

1 Answers1

1

There is no LIKE operator in cassandra. It's "by design". You must use elasticsearch (Solr, Lucene) or similar solutions beside cassandra to develop search abilities.

Andriy Kuba
  • 8,093
  • 2
  • 29
  • 46
  • Sorry for delay, so no way to do this in pure CQL? – RyanJ Sep 23 '15 at 02:34
  • No Way, And no plans for this. If you need search (LIKE) you need to go with some 3rd party indexers. – Andriy Kuba Sep 23 '15 at 07:13
  • I do not know the reason you choice cassandra (I prefer cassandra as well) but you can review other NoSQL solutions if you just start a project - for example mongodb have search ability: http://stackoverflow.com/questions/3305561/how-to-query-mongodb-with-like – Andriy Kuba Sep 23 '15 at 07:34
  • I chose Cassandra for speed and scalability, also on big amount of records, but sometimes happens that a text search is needed, so I'll try with Lucene plugin because actually I didn't find any solution in pure CQL, thanks a lot for the answer, in these days I'll install and try Lucene, but if a field is already a primary key, I can't use Lucene's index on it? Anyway I though that Cassandra had search capabilities, it was developed by Facebook for mail so is strange that there is no search in it. – RyanJ Sep 25 '15 at 13:41
  • I've tried the cassandra-lucene-index , I done an index with this syntax: `CREATE CUSTOM INDEX team_index ON team (name) USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = {'refresh_seconds' : '1','schema' : '{fields:{name : {type : "string"}}}'};` but I get this error: `ServerError: ` – RyanJ Sep 28 '15 at 21:35
  • 1
    @RyanJ you can ask for help or any issue or problem you have in the github issues page of stratio-lucene-index [stratio Lucene Index](https://github.com/Stratio/cassandra-lucene-index/issues). – Javier Cortejoso Jan 27 '16 at 17:03
  • Thanks for the advice, now I'm waiting for Datastax PHP driver to be released in order to upgrade to Cassandra 3 so then I'll be able to retry some tests with Lucene hoping for a better result, if there will be other problems I will report all to Lucene support or mailing list. – RyanJ Feb 01 '16 at 16:11