Workaround for using 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
-
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>>>)
-
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