Confusing title, I know. Will try to explain. I have rows in Cassandra that have something like a type (for purpose of this example let's say they are NEEDED and WANTED). The problem is I want to query a specific number of NEEDED entries by timeuuid interval (e.g after/before uuid=[specific_uuid]) AND also fetch any WANTED entries that are in that interval making a single roundtrip to the db.
I was thinking of something like a union of selects for NEEDED in interval defined by parameter and WANTED in interval defined by parameter and oldest/newest uuid in the first select. However I am not sure that it is possible to do something like this in CQL. Are there any expert Cassandra users to advice me on this? Would be very thankful for any of your input.
This depends really on the table's schema - you will need to put NEEDED
and WANTED
as clustering columns, and the the timeuuid column should be the last clustering column, so you can do range query on it. This article is provides great description of what is possible to do with WHERE
clause in CQL. And this article talks why this works this way.
P.S. if you use DSE distribution with Search, then you have less restrictions as you can use Solr's operators.