Skip to content

Commit 8d802ea

Browse files
author
TheovanKraay
committed
edits after review
1 parent 0d9ec50 commit 8d802ea

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

articles/cosmos-db/cassandra-secondary-index.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
---
2+
title: Indexing in Azure Cosmos DB Cassandra API account
3+
description: Learn how secondary indexing works in Azure Azure Cosmos DB Cassandra API account.
4+
author: TheovanKraay
5+
ms.service: cosmos-db
6+
ms.topic: conceptual
7+
ms.date: 04/04/2020
8+
ms.author: thvankra
9+
ms.reviewer: sngun
10+
---
11+
112
# Secondary indexing in Azure Cosmos DB Cassandra API
213

3-
The Cassandra API in Azure Cosmos DB leverages the underlying Indexing infrastructure to expose the indexing strength that is inherent in the platform. Cassandra API in Azure Cosmos DB supports secondary indexing to create an index on certain attributes. In general, it's not advised to use Apache Cassandra to execute filter queries on the columns that aren't partitioned. You must use ALLOW FILTERING syntax explicitly which, results in a less performant operation. However, in Azure CosmosDB you can run such queries on low cardinality attributes because they fan out across partitions to retrieve the results.
14+
The Cassandra API in Azure Cosmos DB leverages the underlying indexing infrastructure to expose the indexing strength that is inherent in the platform. However, unlike the core SQL API, Cassandra API in Azure Cosmos DB does not index all attributes by default. Instead, it supports secondary indexing to create an index on certain attributes, which behaves the same way as Apache Cassandra.
15+
16+
In general, it's not advised to execute filter queries on the columns that aren't partitioned. You must use ALLOW FILTERING syntax explicitly, which results in an operation that may not perform well. In Azure Cosmos DB you can run such queries on low cardinality attributes because they fan out across partitions to retrieve the results.
417

518
It's not advised to create an index on a frequently updated column. It is prudent to create an index when you define the table. This ensures that data and indexes are in a consistent state. In case you create a new index on the existing data, currently, you can't track the index progress change for the table. If you need to track the progress for this operation, you have to request the progress change via a [support ticket]( https://docs.microsoft.com/azure/azure-portal/supportability/how-to-create-azure-support-request).
619

7-
If you are trying to create a new index on existing data, tracking the index progress change for a table is not exposed. If you need to track the progress - please request the progress change via a support ticket.
20+
21+
> [!NOTE]
22+
> Secondary index is not supported on the following objects:
23+
> - data types such as frozen collection types, decimal, and variant types.
24+
> - Static columns
25+
> - Clustering keys
826
927
## Indexing example
1028

@@ -34,28 +52,20 @@ If you try executing the following statement, you will run into an error that as
3452
select user_id, lastname from sampleks.t1 where lastname='nishu';
3553
```
3654
37-
Although the Cassandra API supports ALLOW FILTERING as mentioned in the previous section, however, it's not recommended. You should instead create an index in the as shown in the following example:
55+
Although the Cassandra API supports ALLOW FILTERING, as mentioned in the previous section, it's not recommended. You should instead create an index in the as shown in the following example:
3856
3957
```shell
4058
CREATE INDEX ON sampleks.t1 (lastname);
4159
```
4260
After creating an index on the "lastname" field, you can now run the previous query successfully. With Cassandra API in Azure Cosmos DB, you do not have to provide an index name. A default index with format `tablename_columnname_idx` is used. For example, ` t1_lastname_idx` is the index name for the previous table.
4361
4462
## Dropping the index
45-
You need to know the index name is to drop the index. Run the `desc schema` command to get the description of your table. The output of this command includes the index name in the format `CREATE INDEX tablename_columnname_idx ON keyspacename.tablename(columnname)'. You can then use the index name to drop the index as shown in the following example:
46-
47-
```
48-
CREATE INDEX tablename_columnname_idx ON keyspacename.tablename(columnname)
49-
```
50-
51-
Use the index name to drop the index as below;
63+
You need to know what the index name is to drop the index. Run the `desc schema` command to get the description of your table. The output of this command includes the index name in the format `CREATE INDEX tablename_columnname_idx ON keyspacename.tablename(columnname)`. You can then use the index name to drop the index as shown in the following example:
5264
5365
```shell
5466
drop index sampleks.t1_lastname_idx;
5567
```
5668
57-
### Note
58-
Secondary index in not supported on:
59-
- Data types like frozen collection types, decimal and variant types.
60-
- Static
61-
- Clustering keys
69+
## Next steps
70+
* Learn how [automatic indexing](index-overview.md) works in Azure Cosmos DB
71+
* [Apache Cassandra features supported by Azure Cosmos DB Cassandra API](cassandra-support.md)

0 commit comments

Comments
 (0)