2

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

Robin Andersson
  • 5,150
  • 3
  • 25
  • 44
Calimero
  • 1,054
  • 1
  • 7
  • 17

2 Answers2

2

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.

jbellis
  • 19,347
  • 2
  • 38
  • 47
1

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".

Nick Berardi
  • 54,393
  • 15
  • 113
  • 135