[ https://issues.apache.org/jira/browse/CASSANDRA-4511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sylvain Lebresne updated CASSANDRA-4511: ---------------------------------------- Attachment: 4511.txt Attaching patch that allows to create index on collections (with the usual syntax) and allow to query them using {{CONTAINS}}, so {noformat} SELECT * FROM myTable WHERE tags CONTAINS 'awesome'; {noformat} What is indexed is the collection values. For lists and sets there is nothing else to index, but for maps, this means we index the map values and it could make sense to index the map keys. Technically, this isn't adding much difficulty since indexing map keys is similar to indexed set values. On the query side, we could just support {noformat} SELECT * FROM myTable WHERE myMap CONTAINS KEY 'foo'; {noformat} and in fact the attached patch contains 80% of what's needed to support this. But it's not yet supported because of 2 reasons: # I realized mid-implementation that if we wanted to support indexing map keys, this means we might need to support indexing both keys and values of the same map, which internally require to support multiple SecondaryIndex object on the same ColumnDefinition and we'd need a bit of refactor of the 2ndary index API to make that work properly. # it's more of a detail but I was not entirely sure what the best syntax to create indexes could be. I supposed we could have something like {noformat} CREATE INDEX ON KEY test(myMap) {noformat} but I'm not entirely fan for some reason. Anyway, I've left most parts of the support for this {{CONTAINS KEY}} in the patch (but the syntax is not allowed). If we decide indexing map keys is something we just don't want, then I'm fine pulling them out of the patch. Otherwise, I'd rather left them (it doesn't add much to the review of the current patch honestly) but finish full support in a followup ticket. I've pushed a dtests for this. > Secondary index support for CQL3 collections > --------------------------------------------- > > Key: CASSANDRA-4511 > URL: https://issues.apache.org/jira/browse/CASSANDRA-4511 > Project: Cassandra > Issue Type: Improvement > Affects Versions: 1.2.0 beta 1 > Reporter: Sylvain Lebresne > Assignee: Sylvain Lebresne > Fix For: 2.1 > > Attachments: 4511.txt > > > We should allow to 2ndary index on collections. A typical use case would be > to add a 'tag set<String>' to say a user profile and to query users based on > what tag they have. -- This message was sent by Atlassian JIRA (v6.1#6144)