0

According to the DataStax collections doc, a collection is always read as a whole. Under the hood C* stores collections just as a list of dynamic columns. For example

books map<text, int>

will be stores as

{name=books:book_name_1, value=2001},
{name=books:book_name_2, value=2002}

How come it is not possible to select a specific key from a map?

EugeneMi
  • 3,475
  • 3
  • 38
  • 57
  • Possible duplicate of [SELECT Specific Value from map](http://stackoverflow.com/questions/16024839/select-specific-value-from-map) – Ashraful Islam Feb 23 '17 at 19:18

2 Answers2

0

What JSON structure is that? (That's not valid JSON.) That's not how a Map would be stored in a column inside Cassandra.

Anyway, You might be looking for the following: http://docs.datastax.com/en/cql/3.1/cql/ddl/ddl_query_collection_c.html

geeves
  • 99
  • 2
  • 4
  • How would it be stored then? My understanding that each map entery is stored in Cassandra as a dynamic column where the Key the a combination of the map name and the key, and the value is the map value – EugeneMi Feb 23 '17 at 18:55
0

Cassandra read every column as a whole.
Cassandra only allow where clause on primary keys only, if you need to filter through normal column you have to create index on it.

For your case you need to split the map and into two field and make key as primary key

For Example :

CREATE TABLE books(
    key text,
    value int,
    primary key(key)
);

Now you can query by key to get value;

SELECT value FROM books WHERE key = ?
Ashraful Islam
  • 12,470
  • 3
  • 32
  • 53