Note that there are some explanatory texts on larger screens.

plurals
  1. POCassandra 1.1 composite keys, columns, and filtering in CQL 3
    text
    copied!<p>I wish to have a table something as follows:</p> <pre><code>CREATE TABLE ProductFamilies ( ID varchar, PriceLow int, PriceHigh int, MassLow int, MassHigh int, MnfGeo int, MnfID bigint, Data varchar, PRIMARY KEY (ID) ); </code></pre> <p>There are 13 fields in total. Most of these represent buckets. Data is a JSON of product family IDs, which are then used in a subsequent query. <strong>Given how Cassandra works, the column names under the hood will be the values. I wish to filter these.</strong></p> <p>I wish to run queries as follows:</p> <pre><code>SELECT Data FROM MyApp.ProductFamilies WHERE ID IN (?, ?, ?) AND PriceLow &gt;= ? AND PriceHigh &lt;= ? AND MassLow &gt;= ? AND MassHigh &lt;= ? and MnfGeo &gt;= ? AND MnfGeo &lt;= ? </code></pre> <ol> <li>I read that Cassandra can only execute WHERE predicates against composite row keys or indexed columns. Is this still true? If so, I would have to make the columns &lt; Data part of the PK.</li> <li>Is it still the case that one has to include all columns from left to right and cannot skip any?</li> <li>Are there any non-optimum points in my design?</li> <li>I would like to add a column "Materials", which is an array of possible materials in a product family. Think pizza toppings, and querying "WHERE Materials IN ('Pineapple')". Without creating a separate inverted index of materials and then performing a manual intersection against the above query, is there any other [more elegant] way of handling this in Cassandra?</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload