Our team has recently switched from self-hosted Cassandra to AWS Keyspaces. Although the "brochure" mentions Cassandra compatibility, we are actually losing some of Cassandra most critical functionality (with the important ones - UDT, Materialized Views and secondary indexes).
Yet the switch is still worth while for us, as self-maintaining Cassandra for a small team is too much overhead.
As part of the migration plan, we decided to replace materialized views with self-maintained tables where absolutely required, and the rest with ALLOW FILTERING
on where we believe the performance implications will be minor for the next 6-12 month time, hoping that Keyspaces will add support for MVs or by implementing a search endpoint using Spark, Elassandra or similar.
We are using Node.js Datastax Cassandra driver with object mapping. As such we would like to keep it this way instead of using raw CQL queries.
However, when trying to run queries using the mapper we can not seem to get the ALLOW FILTERING
feature to work.
We are using the following setup with Node.js & express.
import {Client, mapping, auth, types} from "cassandra-driver";
const fs = require('fs');
const authProvider = new auth.PlainTextAuthProvider(process.env.CASSANDRA_USER!, process.env.CASSANDRA_PWD!);
const sslOptions1 = {
cert: fs.readFileSync('AmazonRootCA1.pem'),
host: 'cassandra.us-east-1.amazonaws.com',
rejectUnauthorized: true
};
export const client = new Client({
contactPoints: ['cassandra.us-east-1.amazonaws.com:9142'],
localDataCenter: 'us-east-1',
authProvider: authProvider,
sslOptions: sslOptions1,
protocolOptions: { port: 9142 },
queryOptions: { consistency: types.consistencies.localQuorum, }
});
// table mapper
export const mapper: mapping.Mapper = new mapping.Mapper(client, {
models: {
products: {
tables: ["products"],
keyspace: "store"
}
}
});
So far so good.
The problem is that the mapper approach doesn't seem to support the 'ALLOW FILTERING'.
So, this works -
await client.execute(
'SELECT * FROM store.products where color = :color ALLOW FILTERING',
{ color: 'red' },
{ prepare: true }
);
But, when using the mapper, there doesn't seem to be a way to toggle the allow filtering option
let productMapper = mapper.forModel("products");
const product: Product = await this.productMapper.find({color: 'red'});
Ideally there would be an option to run
this.productMapper.find({color: 'red'}, {allow_filtering: true});
Searching the documentation does not reveal any related option.
Any help would be greatly appreciated.
Eventually we decided to use Datastax' Astra hosted cassandra - https://www.datastax.com/products/datastax-astra since it supports UDT, Materialized Views and secondary indexes - hence we have not lost functionality or had to make a complete data modeling change that we had to do by using AWS Keyspaces.