Cassandra row key starts with [duplicate] - cassandra

I have a cassandra column family which has a row key like
2012-09-30-05-42-00:30:5856869
I need to query some thing like
select * from cf where key like %5856869%
Currently I am using Astyanax , is same possible in astyanax. If not, which implementation would support it.

LIKE queries are not supported in Cassandra. If you want to query based on part of a key, you'll want to use composite keys. But in this specific case, the 5856869 portion of the key would have to be the first part for you to do what you want. Remember that with Cassandra, you must write your data the way you expect to read it.

None.... you need to write index manually - this is how you handle such things in Cassandra, or you might try full text search: Cassandra full text search like

Related

cassandra where clause, one field from udt

How can I query based on only one field in UDT (Cassandra) ?
I have a UDT which contains marital status and I need data for all the married people
but when I query based on one field it gives empty output
How can I do this ?
short answer - NO, at least not in the stock Cassandra. It's possible to do using the DSE Search, but it adds its own constraints. Maybe when SAI will be implemented some day, it will support indexing of UDT fields. I don't remember if SASI supports this, but it's really not recommended to use. But even if indexing was supported, it's still bad case (maybe except SAI) for Cassandra because it will create big partitions to represent each status.
The general rule is that you need to always query by partition key, with possibility to use secondary indexes when you need to search for another field, but only inside partition. If you need to query by multiple fields that not primary keys, I would suggest to take another database, or use Elasticsearch/Solr (although they aren't very good in geo-distributed environment).

How to Search In cassandra?

i wanna to search in cassandra database.
After much research, I found
Stratio’s Cassandra Lucene Index
Is there another way to simple search on Cassandra?
I mean a simple search query something like in Mysql
I've used this query but his conclusion was wrong
select * from users where uname > 'sa' allow filtering;
It seems to me that you'd want to perform a text search on a non PRIMARY KEY column.
If that's the case, you could use a SSTable Attached Secondary Index (SASI) that would allow to exactly search as you wrote. Specifically, you'd need to create a CONTAINS index to perform inequality searches on text fields. You need Cassandra 3.4 and later.

Cassandra implementing string search pattern

Does Cassandra support like attribute on a string. I feel like based on partition system in cassandra, this type of query is not even supported in cassandra.
If I have model post
CREATE TABLE Post (
title text PRIMARY KEY,
description text,
);
How can I search title and description for a particular string pattern.?
what are options to implement this in cassandra.?
Do I need to pull all key strings using some text analytics API from title and description and store separately in a different table ?
You're right, wildcard searches are not supported in Cassandra, given its key-value structure. A common solution people used is to use another product like Solr or Elastisearch to create indexes off of your Cassandra data.
Cassandra 3.4 and later includes support for a new type of indexing that will allow you to do partial matching and full text search. Details can be found in the DataStax documentation: Using a SSTable Attached Secondary Index (SASI).

Design approach cassandra for Rowkey and already exists check

I am new to cassandra and my cassandra is giving lot of read timeout errors..tweaked timout but still problem may be problem with design (for my application cassandra expected to store trillions of data):
Question 1 : In an all my cassandra tables i use UUID as rowkey...but for few tables just for maintainence i break that rule like in user table i make email id as rowkey....so that looking at tables i can understand data stored...IS using UUID right approach for huge case and second approach for user table is right or not ???????????
Question 2 : i have one relations table with startNodeId, relationTypeId, endNodeId...rowkey for that is UUID which is relationId.....i define secondary indexes on startNode, relationType, endNode as i can have lookup by any of them by business case.........becuase of that for each new row i have to do get to check ALREADY existing relation or not....One approach to avoid existing check is : i take startNodeId, relationTypeId, endNodeId SORT them and create HASH CODE and use that as ROWKEY...so my already checking explicitly will be avoided here..........IS THIS RIGHT approach ???????
Please guide me i am stuck at these thoughts...any guidance will really help me
Answering to your first question, until and unless you are comfortable in handling the rowkey with non-uuid value, its great also easier to track else go for the UUID.
Regarding to your second question, why don't you try the compound key. You don't have to maintain hashcode like stuffs, leave it on Cassandra.
1) Better use natural keys not UUIDs. Email, timestamp, composite primary keys, and so on. Using UUID is an approach from RDBMS world, you should avoid it in Cassandra
2) Read-modify-update is wrong pattern for Cassandra. Try rewritng data, if your business case allows this. Or just use timestamp and get the row with latest timestamp (don't forget about TTL).

Searching for data in Cassandra

I understand that with Cassandra, it is possible to search using secondary indexes, but the problem is I am trying to search on information from a super column. So I want to search on a value within a super column, but return everything within that row (not just that one super column).Is this possible to do?
My understanding is that Facebook and Twitter use Cassandra, and so it would seem quite pointless if they have search facilities but it is not possible to search using something built into Cassandra.
Please correct me if I have not understood the proper use of super columns within Cassandra.
Thanks.
You cannot search on a super column value, as secondary indexes are not supported for SCs. You should avoid using super columns for a variety of reasons, but mostly because they are effectively deprecated. Most super column use cases are supported through the use of composites--which will ultimately replace SCs. In the meantime, if you must search for a value in a SC, you will have to do so manually (i.e. in code) or using an external tool such as Hadoop or Solr.

Resources