go - Secondary indexes on composite keys in cassandra -


i have table in cassandra

create table global_product_highlights (   deal_id text,   product_id text,   highlight_strength double,   category_id text,   creation_date timestamp,   rank int,   primary key (deal_id, product_id, highlight_strength) ) 

when fire below query in golang

err = session.query("select product_id global_product_highlights category_id=? order highlight_strength desc",default_category).scan(&prodid_array) 

i error : order 2ndary indexes not supported.

i have index on category_id.

i don't understand how secondary index applied on composite keys in cassandra.

appreciate if explain , rectify one.

the order by clause in cassandra works on first clustering column (2nd column in primary key), in case product_id. this datastax doc states that:

querying compound primary keys , sorting results order clauses can select single column only. column has second column in compound primary key.

so, if want have table sorted highlight_strength, you'll need make field first clustering column.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -