Table 1 describes the table and index schema used throughout the SAI examples.

Table and index schema

Table name

Table

Indexes

comments_vs for vector search

CREATE TABLE IF NOT EXISTS cycling.comments_vs (
  record_id timeuuid,
  id uuid,
  commenter text,
  comment text,
  comment_vector VECTOR <FLOAT, 5>,
  created_at timestamp,
  PRIMARY KEY (id, created_at)
)
WITH CLUSTERING ORDER BY (created_at DESC);
CREATE CUSTOM INDEX IF NOT EXISTS ann_index 
  ON cycling.comments_vs(comment_vector) USING 'StorageAttachedIndex';

comments_vs

CREATE TABLE IF NOT EXISTS cycling.comments_vs (
  record_id timeuuid,
  id uuid,
  commenter text,
  comment text,
  comment_vector VECTOR <FLOAT, 5>,
  created_at timestamp,
  PRIMARY KEY (id, created_at)
)
WITH CLUSTERING ORDER BY (created_at DESC);
CREATE CUSTOM INDEX commenter_idx 
    ON cycling.comments_vs (commenter) 
    USING 'StorageAttachedIndex';
CREATE CUSTOM INDEX created_at_idx 
    ON cycling.comments_vs (created_at) 
    USING 'StorageAttachedIndex';
CREATE CUSTOM INDEX ann_index 
    ON cycling.comments_vs (comment_vector) 
    USING 'StorageAttachedIndex';

rank_by_year_and_name

CREATE TABLE IF NOT EXISTS cycling.rank_by_year_and_name (
  race_year int,
  race_name text,
  cyclist_name text,
  rank int,
  PRIMARY KEY ((race_year, race_name), rank)
);
CREATE CUSTOM INDEX commenter_idx 
    ON cycling.comments_vs (commenter) 
    USING 'StorageAttachedIndex';
CREATE CUSTOM INDEX created_at_idx 
    ON cycling.comments_vs (created_at) 
    USING 'StorageAttachedIndex';
CREATE CUSTOM INDEX ann_index 
    ON cycling.comments_vs (comment_vector) 
    USING 'StorageAttachedIndex';

cyclist_career_teams

CREATE TABLE IF NOT EXISTS cycling.cyclist_career_teams (
  id UUID PRIMARY KEY,
  lastname text,
  teams set<text>
);
CREATE CUSTOM INDEX teams_idx 
    ON cycling.cyclist_career_teams (teams) 
    USING 'StorageAttachedIndex';

upcoming_calendar

CREATE TABLE IF NOT EXISTS cycling.upcoming_calendar (
  year int,
  month int,
  events list<text>,
  PRIMARY KEY (year, month)
);
CREATE CUSTOM INDEX events_idx 
    ON cycling.upcoming_calendar (events) 
    USING 'StorageAttachedIndex';

cyclist_teams

CREATE TABLE IF NOT EXISTS cycling.cyclist_teams (
  id uuid PRIMARY KEY,
  firstname text,
  lastname text,
  teams map<int, text>
);
CREATE INDEX IF NOT EXISTS team_year_keys_idx
ON cycling.cyclist_teams ( KEYS (teams) );

CREATE INDEX IF NOT EXISTS team_year_values_idx
ON cycling.cyclist_teams ( VALUES (teams) );

CREATE INDEX IF NOT EXISTS team_year_entries_idx
ON cycling.cyclist_teams ( ENTRIES (teams) );

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