Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: Right Click CREATE/ALTER/DROP Custom Index and creating tree grouping for Custom Indexes #643

Open
millerjp opened this issue Dec 19, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request right click
Milestone

Comments

@millerjp
Copy link
Contributor

millerjp commented Dec 19, 2024

Indexes

-- Indexes
	|- All
	|- Secondary Indexes (2i)
	|- Storage-attached Indexes (SAI)
	|- SSTable Secondary Indexes (SASI)
	|- Vector Indexes
	|- Custom Indexes
	|- Collection Indexes

Secondary Indexes (2i)

https://cassandra.apache.org/doc/5.0/cassandra/developing/cql/indexing/2i/2i-overview.html

Your looking for the "CREATE INDEX " without the USING sai`` and none of the others

CREATE INDEX IF NOT EXISTS rank_idx
ON cycling.rank_by_year_and_name (rank);

Storage-attaached Indexes (SAI)

https://cassandra.apache.org/doc/5.0/cassandra/developing/cql/indexing/sai/sai-overview.html

You cannot define an SAI index based on the partition key when it’s comprised of only one column. If you attempt to create an SAI index in this case, SAI issues an error message.

Your looking for the "using sai"

All column date types except the following are supported for SAI indexes:

  • counter
  • non-frozen user-defined type (UDT)
CREATE INDEX lastname_sai_idx ON cycling.cyclist_semi_pro (lastname)
USING 'sai'
WITH OPTIONS = {'case_sensitive': 'false', 'normalize': 'true', 'ascii': 'true'};

CREATE INDEX age_sai_idx ON cycling.cyclist_semi_pro (age)
USING 'sai';

CREATE INDEX country_sai_idx ON cycling.cyclist_semi_pro (country)
USING 'sai'
WITH OPTIONS = {'case_sensitive': 'false', 'normalize': 'true', 'ascii': 'true'};

CREATE INDEX registration_sai_idx ON cycling.cyclist_semi_pro (registration)
USING 'sai';

SSTable Secondary Indexes (SASI Indexes)

https://cassandra.apache.org/doc/5.0/cassandra/developing/cql/SASI.html

Your looking for the "CREATE CUSTOM INDEX", "USING" and "SASIIndex" (just the word, not the fully qualified package)

CREATE CUSTOM INDEX ON sasi (first_name) USING 'org.apache.cassandra.index.sasi.SASIIndex'
        ... WITH OPTIONS = {
        ... 'analyzer_class':
        ...   'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer',
        ... 'case_sensitive': 'false'
        ... };

cqlsh:demo> CREATE CUSTOM INDEX ON sasi (last_name) USING 'org.apache.cassandra.index.sasi.SASIIndex'
        ... WITH OPTIONS = {'mode': 'CONTAINS'};

cqlsh:demo> CREATE CUSTOM INDEX ON sasi (age) USING 'org.apache.cassandra.index.sasi.SASIIndex';

cqlsh:demo> CREATE CUSTOM INDEX ON sasi (created_at) USING 'org.apache.cassandra.index.sasi.SASIIndex'
        ...  WITH OPTIONS = {'mode': 'SPARSE'};

Vector Indexes

Cassandra 5.0+ only

This is an SAI index on a vector data type. You will need to see if the data type is a vector data type to detect

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 INDEX IF NOT EXISTS ann_index
  ON cycling.comments_vs(comment_vector) USING 'sai'
 

Collection Indexes

You need to check that the column the index is on is a collection data type

CREATE INDEX IF NOT EXISTS teams_idx
ON cycling.cyclist_career_teams (teams);

CREATE INDEX IF NOT EXISTS team_year_keys_idx
ON cycling.cyclist_teams ( KEYS (teams) );

CREATE INDEX IF NOT EXISTS blist_idx
ON cycling.birthday_list ( ENTRIES(blist) )


CREATE INDEX IF NOT EXISTS blist_values_idx
ON cycling.birthday_list ( VALUES(blist) )

CREATE INDEX IF NOT EXISTS rnumbers_idx
ON cycling.race_starts ( FULL(rnumbers) );

Custom Indexes

https://cassandra.apache.org/doc/5.0/cassandra/reference/cql-commands/create-custom-index.html

Anything using CREATE CUSTOM INDEX which is not an SAI index or anything else. There are a few around eg

CREATE CUSTOM INDEX "PaxosUncommittedIndex" ON system.paxos () USING 'org.apache.cassandra.service.paxos.uncommitted.PaxosUncommittedIndex';
@millerjp millerjp added enhancement New feature or request right click labels Dec 19, 2024
@millerjp millerjp added this to the RightClick milestone Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request right click
Projects
None yet
Development

No branches or pull requests

2 participants