# How do we create global secondary index on set types?

**URL:** <https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451>\
**Category:** ScyllaDB\
**Created:** [April 11, 2023, 8:20am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451 "2023-04-11T08:20:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![corneredrat](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/corneredrat/32/1240_2.png) [@corneredrat](https://forum.scylladb.com/u/corneredrat)\
**Post date:** [April 11, 2023, 8:20am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451/1 "2023-04-11T08:20:07Z")

</div>

Hi good people,

I was trying to create secondary index on a column of type “set” but not sure if its possible.

for example, I have a table as follows:

```auto
CREATE KEYSPACE company WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '1'} AND durable_writes = true;

CREATE TABLE employee (
    id bigint PRIMARY KEY,
    name text,
    address text,
    department text,
    subordinate_ids set<bigint>);

```

here, I want to create secondary index / materialized views on `subordinate_ids` .

please suggest a way on how this can be achieved.

Best regards,  
Raghu

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [April 11, 2023, 9:27am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451/2 "2023-04-11T09:27:19Z")

</div>

Scylla does support global secondary indexes on collection columns, starting with ScyllaDB 5.2. This is currently in the process of being released, currently at RC3. I suggest taking it for a spin trying out this new feature.

---

<div class="post-metadata">

**Author:** ![corneredrat](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/corneredrat/32/1240_2.png) [@corneredrat](https://forum.scylladb.com/u/corneredrat)\
**Post date:** [April 11, 2023, 9:58am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451/3 "2023-04-11T09:58:01Z")

</div>

Thanks for the reply @Botond_Denes … could you please share any document regarding creating secondary indexes with collection type?

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [April 11, 2023, 10:07am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451/4 "2023-04-11T10:07:06Z")

</div>

See our general documentation on secondary indexes here: [Global Secondary Indexes | ScyllaDB Docs](https://docs.scylladb.com/branch-5.2/using-scylla/secondary-indexes.html) and [scylladb/secondary\_index.md at master · scylladb/scylladb · GitHub](https://github.com/scylladb/scylladb/blob/master/docs/dev/secondary_index.md).

For a column of set type, the create statement looks something like this:

```auto
CREATE INDEX employee_by_subordinate_ids ON company.employee (VALUES(subordinate_ids));

```

---

<div class="post-metadata">

**Author:** ![corneredrat](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/corneredrat/32/1240_2.png) [@corneredrat](https://forum.scylladb.com/u/corneredrat)\
**Post date:** [April 11, 2023, 10:20am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451/5 "2023-04-11T10:20:27Z")

</div>

worked like a charm! thanks @Botond_Denes

I had to get rid of `.` in index name for it to work though…

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [April 11, 2023, 10:32am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451/6 "2023-04-11T10:32:27Z")

</div>

Thanks, I edited my answer, can you please check if it is correct now?

---

<div class="post-metadata">

**Author:** ![corneredrat](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/corneredrat/32/1240_2.png) [@corneredrat](https://forum.scylladb.com/u/corneredrat)\
**Post date:** [April 11, 2023, 10:48am UTC](https://forum.scylladb.com/t/how-do-we-create-global-secondary-index-on-set-types/451/7 "2023-04-11T10:48:11Z")

</div>

works as it is now, thanks @Botond_Denes
