Create a CQL collection

In these advanced DSE Search tutorial steps, you create a Cassandra table having a map collection column.

Using dynamic fields, you process multiple Solr fields the same way by using a generic prefix or suffix to reference the field. In this task, you create a Cassandra table having a map collection column. This column will correspond to a dynamic field that you set up in the Solr schema in the next task.

Procedure

  1. Create a keyspace.
    CREATE KEYSPACE mykeyspace
      WITH REPLICATION = {'class':'NetworkTopologyStrategy', 'Solr':1};
    
    USE mykeyspace;
  2. Create a table having a map collection column. Apply the dynamic field naming convention that you plan to use in the schema to the column name.
    CREATE TABLE hits (
      song uuid,
      lang_ map<text, text>,
      PRIMARY KEY (song)
    );
  3. Insert the following data about Italian and Hawaiian songs into the hits table. Use the lang_ to prefix the first component of each map pair.
    INSERT INTO hits (song, lang_) VALUES ( 62c36092-82a1-3a00-93d1-46196ee77204, { 'lang_i-title'  : 'La Vita E La Felicita', 'lang_i-artist' : 'Michele Bravi' });
    INSERT INTO hits (song, lang_) VALUES ( 8a172618-b121-4136-bb10-f665cfc469eb, { 'lang_h-title'  : 'Blew it', 'lang_h-artist' : 'Maoli f/ Fiji' });
    INSERT INTO hits (song, lang_) VALUES ( a3e64f8f-bd44-4f28-b8d9-6938726e34d4, { 'lang_i-title'  : 'Dimmi Che Non Passa Felicita', 'lang_i-artist' : 'Violetta' });