Tuples and UDTs as CQL map values

DSE Search does not support using tuples and UDTs as CQL map values. Use this workaround to simulate a map-like data model.

Procedure

  1. Declare a collection of tuples or UDTs that have a type field that represents what would have been the map key:

    Create the tuple type. The tuple type applies to tuples and UDTs.

    CREATE TYPE Address (type text, street text, city text)

    Create table for UDT:

    CREATE TABLE Person (name text primary key, addresses set<frozen<address>>)

    Or create a table for a tuple:

    CREATE TABLE Person (name text primary key, addresses set<frozen<tuple<text, text, text>>>)
  2. Using this collection of tuples or UDTs as a map-like data model, it is possible to query for person addresses of a given type (key).

    For example, to query for persons whose home address is in London:

    {!tuple}addresses.type:Home AND
        addresses.city:London

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com