Index on cyclist_name

Create an experimental secondary index.

USE cycling;

DROP INDEX IF EXISTS fn_prefix;
DROP INDEX IF EXISTS fn_contains;
DROP INDEX IF EXISTS fn_sparse;
DROP INDEX IF EXISTS fn_notcasesensitive;
DROP INDEX IF EXISTS stdanalyzer_idx;

// START-prefix
CREATE CUSTOM INDEX IF NOT EXISTS fn_prefix 
ON cycling.comments (commenter) 
USING 'org.apache.cassandra.index.sasi.SASIIndex';
// END-prefix

// START-contains 
CREATE CUSTOM INDEX IF NOT EXISTS fn_contains 
ON cycling.comments (comment) 
USING 'org.apache.cassandra.index.sasi.SASIIndex'
WITH OPTIONS = {
  'mode' : 'CONTAINS'
};
// END-contains

// START-sparse
CREATE CUSTOM INDEX IF NOT EXISTS fn_sparse 
ON cycling.comments (record_id) 
USING 'org.apache.cassandra.index.sasi.SASIIndex'
WITH OPTIONS = {
  'mode' : 'SPARSE'
};
// END-sparse

// START-case
CREATE CUSTOM INDEX IF NOT EXISTS fn_notcasesensitive 
ON cycling.comments (comment) 
USING 'org.apache.cassandra.index.sasi.SASIIndex'
WITH OPTIONS = { 
  'analyzer_class' : 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer',
  'case_sensitive' : 'false'
};
// END-case

// START-stdanalyzer
CREATE CUSTOM INDEX IF NOT EXISTS stdanalyzer_idx 
ON cycling.comments (comment) 
USING 'org.apache.cassandra.index.sasi.SASIIndex' 
WITH OPTIONS = {
  'mode' : 'CONTAINS',
  'analyzer_class' : 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer',
  'analyzed' : 'true',
  'tokenization_skip_stop_words' : 'and, the, or',
  'tokenization_enable_stemming' : 'true',
  'tokenization_normalize_lowercase' : 'true',
  'tokenization_locale' : 'en'
};
// END-stdanalyzer

// START-dprefix
DROP INDEX IF EXISTS fn_prefix;
// END-dprefix

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