What is the default index in Cassandra? - indexing

I am using cassandra DSE 6.8. I know that there are several indexes used in Cassandra: 2nd index, SASI, SAI, search index, ...
When I create an index on a column:
CREATE INDEX status_idx ON table_name (status);
What is the name of default index ?

There is only one native index in open-source Cassandra, commonly referred to as secondary index. All indexes created with the CQL command CREATE INDEX are secondary indexes.
Alternatively, the SSTable-attached secondary index (SASI) is a custom index and therefore needs to be explicitly created with the keyword CUSTOM and the custom class SASIIndex specified:
CREATE CUSTOM INDEX ... USING 'org.apache.cassandra.index.sasi.SASIIndex'
Note that SASI is considered experimental by the Cassandra community and is disabled by default as I've explained in this post -- https://community.datastax.com/questions/12403/. They are not recommended for use in production.
DataStax Enterprise which ships with production-certified distributions of Apache Cassandra has an advanced DSE Search feature that allows users to perform complex full-text Solr searches on CQL tables indexed with Lucene. The custom indexes are created with the class Cql3SolrSecondaryIndex:
CREATE CUSTOM INDEX ... USING 'com.datastax.bdp.search.solr.Cql3SolrSecondaryIndex'
Astra DB, a fully-managed cloud-native Cassandra-as-a-service, includes the new Storage-Attached Indexing (SAI), a globally-distributed index for Cassandra. Indexes are created using the custom class StorageAttachedIndex:
CREATE CUSTOM INDEX ... USING 'StorageAttachedIndex'
The SAI enhancement in not yet available in open-source Cassandra but has been donated by DataStax and is awaiting acceptance by the Cassandra project (see CEP-7, CASSANDRA-16052). Cheers!

In this case, since a name has been provided, it will be status_idx. If a name was not provided, one is auto-generated based on the table and column:
table_name + _ + column_name + _idx
So in this case, it would be:
table_name_status_idx
Edit
Ahh…I get it now.
CREATE INDEX creates a secondary index.
CREATE CUSTOM INDEX creates a SASI index.

Related

DataStax/Tinkerpop - Ability to remove a property

I am looking a way to remove a propertyKey in the schema. The documentation here explains how to add properties but no information about the removal. Does that mean that it is not possible?
Since DataStax relies on Cassandra that supports table altering I guess there is some way to achieve that, otherwise how to deal with dynamic schemas where properties can be added or removed?
Edit: For more clarity I want to remove the property both in the schema and in the data. Exactly like the ALTER DROP in SQL:
ALTER TABLE table_name
DROP COLUMN column_name
The DSE Graph reference for dropping data, schema or graphs is: http://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/using/dropSchemaDataStudio.html
As DSE Graph is built on the standards of TinkerPop, you can also leverage the TinkerPop 3 API references here - http://tinkerpop.apache.org/docs/current/reference/#_tinkerpop3.
For this item, i believe you are looking for .drop(). http://tinkerpop.apache.org/docs/current/reference/#drop-step
From the above link, if you want to remove a property, do this: .properties("X").drop()

Create index on type *and* label when using Tinkerpop3?

Tinkerpop 3 introduces the great concept of labels. We are heavily using this feature where it identifies the schema used.
However, i see no support for labels when using indexes:
Graph#createIndex(String key, Class<E> elementClass)
Is there any way to create label specific indexes?
UPDATE
I am using TinkerGraph (in memory reference implementation).

Does neo4j auto index work for MATCH clause?

We have turned on auto indexing for both nodes and relationship. By default NEO4J will create an index named "node_auto_index" for nodes and "relationship_auto_index" for relationships. But the MATCH queries seem to be under performing (comparing to a similar data set in Elasticsearch). Looks like they are not using the indexes.
Is there a way to make the MATCH clause use the auto_index ?
We also tried looking at the schema index. Looks like it can only create node indexes. Our queries use some properties on relationships and hence even after using the schema index the queries are unacceptable in performance.
Is there a way to create schema relationship indexes ?
The node_auto_index is not used for match, you would have to use the start clause to access that legacy index.
e.g.
START user=node:node_auto_index(name="Siddarth")
MATCH (user)-[:KNOWS]->(friend)
RETURN friend
In Neo4j 2.0 you can create an index or unique constraint instead
create index on :User(name);
and then use it in MATCH
MATCH (user:User {name:"Siddarth"})-[:FRIEND]->(friend)
RETURN friend
See also the manual: http://docs.neo4j.org/chunked/milestone/query-schema-index.html
and the cypher refcard: http://neo4j.org/resources/cypher

Creation of compund unique contraint in neo4j 2.0

i'm using neo4j to create a versioned graph database, and i'm having some troubles to implement unique constraints in the database.
I want to know if is possible to do something like
CREATE CONSTRAINT ON (u:CaliopeUser) ASSERT u.timestampt+u.name IS UNIQUE
Or any other idea about how to implenment the uniqueness constraint in neo4j for a versioned database.
In 2.0 compound schema indexes are not possible. The recommended workaround is to create another property holding the compound value (maybe a transactionEventHandler might help with automating this) and use a index on that property.
I expect support for indexes on compound properties in some future release.

Secondary Index in OrientDB

Is there a way to specify a secondary index in OrientDB?
I need something that have all the documents references that have a specified field (like indexable=true).
All indexes in OrientDB are like the secondary of RDBMS (the primary doesn't exists because the RID is auto-assigned). So just create indexes following the documentation: https://github.com/nuvolabase/orientdb/wiki/Indexes