# Creating an index on User Defined Types

**URL:** <https://forum.scylladb.com/t/creating-an-index-on-user-defined-types/2178>\
**Category:** ScyllaDB\
**Tags:** collections, data-model, secondary-index, udt\
**Created:** [June 18, 2024, 8:42am UTC](https://forum.scylladb.com/t/creating-an-index-on-user-defined-types/2178 "2024-06-18T08:42:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/guy/32/9_2.png) [@Guy](https://forum.scylladb.com/u/Guy)\
**Post date:** [June 18, 2024, 8:42am UTC](https://forum.scylladb.com/t/creating-an-index-on-user-defined-types/2178/1 "2024-06-18T08:42:42Z")

</div>

> [@](#):
>
> [**Originally from the User Slack**](https://scylladb-users.slack.com/)
> 
> ![Dhruv_garg](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/337e40d842d6eb761d4781297e28cd57acd34dc8.jpeg) **@Dhruv\_garg:** can we create index on user defined types?  
> e.g. `CREATE INDEX ON nudge.rewards_coupon_code (client_id, coupon.code);`
> 
> ![Felipe_Cardeneti_Mendes](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/233a9d524fbc97e39f08633c16b3dd2575d1d1f4.jpeg) **@Felipe\_Cardeneti\_Mendes:** Well, not for specific fields yet. You can index the entire UDT column
> 
> ![Dhruv_garg](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/337e40d842d6eb761d4781297e28cd57acd34dc8.jpeg) **@Dhruv\_garg:** so after indexing whole column, I can search on it’s specific fields as well?  
> like `where coupon.code = 'xyz'`, will this work?
> 
> ![Felipe_Cardeneti_Mendes](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/233a9d524fbc97e39f08633c16b3dd2575d1d1f4.jpeg) **@Felipe\_Cardeneti\_Mendes:** Nope, the entire column gets indexed not individual fields atm
> 
> ![Dhruv_garg](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/337e40d842d6eb761d4781297e28cd57acd34dc8.jpeg) **@Dhruv\_garg:** how is that helpful? what kind of queries can I run using that?
> 
> ![Felipe_Cardeneti_Mendes](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/233a9d524fbc97e39f08633c16b3dd2575d1d1f4.jpeg) **@Felipe\_Cardeneti\_Mendes:** Of course 1:1 queries where you require an exact match on the full UDT. You can open an issue to enable indexing individual fields.  
> IIUC it should be simple with the existing infrastructure to index collection columns, but we’ll likely also discuss compatibility wrt [https://issues.apache.org/jira/browse/CASSANDRA-6382](https://issues.apache.org/jira/browse/CASSANDRA-6382) which is not yet solved by cassandra as well
> 
> ![Dhruv_garg](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/337e40d842d6eb761d4781297e28cd57acd34dc8.jpeg) **@Dhruv\_garg:** got it, thanks
