Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

gmldba_107428 avatar image
gmldba_107428 asked ·

How can I query tables with set datatypes? (I don't want to use allow filtering option)

I have the following table:

CREATE TABLE servers (
    id uuid,
    hostname text,
    ip inet,
    dc text,
    db text,
    groups set<text>,
    windows boolean,
    PRIMARY KEY ((id, hostname, ip), dc)
) WITH CLUSTERING ORDER BY (dc ASC)

I want to filter on groups. How can I do this? Do I need an Index? I don't want to use allow filtering option. Is there a way I can improve the schema?

schemaqueryingselect
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

@gmldba_107428 you will need to an index on the groups column in order to query it. But be warned that the same caveats apply as other indexes. For more info, see Indexing a collection. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.