Reputation: 191
I'm trying to select records by filtering value on a map column.
name (text) | last (text) | languages(map<text:text>)
john | stith | {12:English, 123:Spanish}
Jane | Doe | {34:Italian, 123:Spanish}
I'm trying select records have only have Italian as a value. but on the documentation only shows how to get records from the by the key.
by filtering by Italian I should get Jane Doe on the example above. How can I accomplish my filtering?
Upvotes: 1
Views: 2614
Reputation: 3957
you need to create an index on value of the map. Assuming an index on map value is created, filter the data using a value in the map
SELECT * FROM table WHERE languages CONTAINS 'Italian';
To create an index on the values
CREATE INDEX mymapvalues ON tableName(languages);
see here for more info https://docs.datastax.com/en/cql/3.1/cql/ddl/ddlIndexColl.html
Upvotes: 3