You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/cassandra-secondary-index.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ It's not advised to create index on a frequently updated column. It is prudent t
28
28
### Create a table
29
29
Use the following commands to create a key space and a table:
30
30
31
-
```
31
+
```shell
32
32
CREATE KEYSPACE sampleks WITH REPLICATION = { 'class':'SimpleStrategy'}
33
33
CREATE TABLE sampleks.t1(user_id int PRIMARY KEY, lastname text) WITH cosmosdb_provisioned_throughput=400;
34
34
```
@@ -37,7 +37,7 @@ CREATE TABLE sampleks.t1(user_id int PRIMARY KEY, lastname text) WITH cosmosdb_p
37
37
38
38
Insert the following user data into the table:
39
39
40
-
```
40
+
```shell
41
41
insert into sampleks.t1(user_id,lastname) values (1, 'Nishu');
42
42
insert into sampleks.t1(user_id,lastname) values (2, 'John');
43
43
insert into sampleks.t1(user_id,lastname) values (3, 'Bat');
@@ -52,21 +52,21 @@ insert into sampleks.t1(user_id,lastname) values (9, 'Jagan');
52
52
53
53
If you try executing the following statement, you will run into an error that asks you to use allow filtering:
54
54
55
-
```
55
+
```shell
56
56
selectuser_id, lastname from gks1 .t1 where last_name='Nishu';
57
57
```
58
58
59
59
### Create an index
60
60
61
61
Create an index with the following command:
62
62
63
-
```
63
+
```shell
64
64
CREATE INDEX ON sampleks.t1 (lastname)
65
65
```
66
66
67
67
Next you can run queries with filter on the indexed field:
68
68
69
-
```
69
+
```shell
70
70
selectuser_id, lastname from gks1.t1 where user_id=1;
71
71
```
72
72
@@ -76,9 +76,12 @@ With Cassandra API in Azure Cosmos DB, you do not have to provide an index name.
76
76
77
77
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. You can then use the index name to drop the index as shown in the following example:
78
78
79
-
```
79
+
```shell
80
80
desc schema;
81
81
drop index sampleks.t1_lastname_idx;
82
82
```
83
83
84
-
## Next steps
84
+
## Next steps
85
+
86
+
* Learn how [automatic indexing](index-overview.md) works in Azure Cosmos DB
87
+
* [Apache Cassandra features supported by Azure Cosmos DB Cassandra API](cassandra-support.md)
0 commit comments