Fluentcassandra Filter Problem

475 Views Asked by At

i'm new in FluentCassandra and Cassandra.

I have a Problem to filter data from a range of value. In my opinion i can use a Generic List to filter the result, but i don't no how?!

In MSSQL i use this (SELECT * FROM TABLE WHERE Row1 like '%search%').

CassandraSuperColumnFamily<UTF8Type, UTF8Type> familyname= db.GetColumnFamily<UTF8Type, UTF8Type>("Messages");
var results= familyname.Get("key")
                .Take(5)
                .FirstOrDefault()
                .AsDynamic();

Maybe some one can help me?!

Thanks calimero

2

There are 2 best solutions below

1
On

Searching for a substring requires an inefficient sequential scan. Cassandra doesn't make that easy, because it's usually the wrong thing to do:

  • if you want full-text search, you should use Solandra
  • if you want to do analytical queries, you should use Pig or Hive on top of Hadoop, which will parallelize the work across the cluster

If you absolutely must do a non-parallel seq scan, you'll have to page through the rows manually and check for your substring in C# code.

0
On

With what jbellis said, column name scanning is now supported in Cassandra 0.7 and greater. To scan the column names for a specific value you can do:

var results = familyname.Get(startKey: "key", keyCount: 30, family => family["last_name"] == "Smith")
    .Take(5)
    .FirstOrDefault()
    .AsDynamic() 

The above code will start at the specified key and scan the next 30 keys for a column with the name "last_name" and the value of "Smith".